diff --git a/packages/app/src/microsoft/teams/app/app.py b/packages/app/src/microsoft/teams/app/app.py index 8890ff6c..f3bfe526 100644 --- a/packages/app/src/microsoft/teams/app/app.py +++ b/packages/app/src/microsoft/teams/app/app.py @@ -12,16 +12,17 @@ from dependency_injector import providers from dotenv import find_dotenv, load_dotenv from microsoft.teams.api import ( + Account, + ActivityParams, ApiClient, ClientCredentials, + ConversationAccount, ConversationReference, Credentials, JsonWebToken, + MessageActivityInput, ) -from microsoft.teams.api.activities.message.message import MessageActivityInput -from microsoft.teams.api.clients.conversation.activity import ActivityParams -from microsoft.teams.api.models.account import Account, ConversationAccount -from microsoft.teams.cards.adaptive_card import AdaptiveCard +from microsoft.teams.cards import AdaptiveCard from microsoft.teams.common import Client, ClientOptions, ConsoleLogger, EventEmitter, LocalStorage from .app_events import EventManager diff --git a/packages/app/src/microsoft/teams/app/app_process.py b/packages/app/src/microsoft/teams/app/app_process.py index 19cd7005..bf762fca 100644 --- a/packages/app/src/microsoft/teams/app/app_process.py +++ b/packages/app/src/microsoft/teams/app/app_process.py @@ -18,7 +18,7 @@ TokenProtocol, is_invoke_response, ) -from microsoft.teams.cards.adaptive_card import AdaptiveCard +from microsoft.teams.cards import AdaptiveCard from microsoft.teams.common import Client, ClientOptions, LocalStorage, Storage if TYPE_CHECKING: diff --git a/packages/cards/src/microsoft/teams/cards/__init__.py b/packages/cards/src/microsoft/teams/cards/__init__.py index a7fd97b8..99359c7b 100644 --- a/packages/cards/src/microsoft/teams/cards/__init__.py +++ b/packages/cards/src/microsoft/teams/cards/__init__.py @@ -3,7 +3,4 @@ Licensed under the MIT License. """ -from .adaptive_card import AdaptiveCard - -# Combine all exports from submodules -__all__ = ["AdaptiveCard"] +from .core import * diff --git a/packages/cards/src/microsoft/teams/cards/adaptive_card.py b/packages/cards/src/microsoft/teams/cards/adaptive_card.py deleted file mode 100644 index 8432ed2e..00000000 --- a/packages/cards/src/microsoft/teams/cards/adaptive_card.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the MIT License. -""" - -from microsoft.teams.api.models.custom_base_model import CustomBaseModel - - -class AdaptiveCard(CustomBaseModel): - pass diff --git a/packages/cards/src/microsoft/teams/cards/core.py b/packages/cards/src/microsoft/teams/cards/core.py new file mode 100644 index 00000000..a120683c --- /dev/null +++ b/packages/cards/src/microsoft/teams/cards/core.py @@ -0,0 +1,7775 @@ +""" +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the MIT License. +""" + +# This file was automatically generated by a tool on 08/20/2025, 10:35 PM UTC. +# It includes declarations for Adaptive Card features available in Teams, Copilot, Outlook, Word, Excel, PowerPoint. + +from typing import Any, Dict, List, Literal, Optional, Self, Union + +from pydantic import AliasGenerator, BaseModel, ConfigDict, Field +from pydantic.alias_generators import to_camel + + +class SerializableObject(BaseModel): + """Base class for all serializable objects.""" + + @staticmethod + def validation_alias_generator(field: str) -> str: + "Handles deserialization aliasing" + + # Handle parameters that start with "@" + if field.startswith("at_"): + return f"@{field[3:]}" + + # Handles from field which is a duplicate reserved internal name + if field == "from_": + return "from" + + # All other fields are converted to camelCase + return to_camel(field) + + @staticmethod + def serialization_alias_generator(field: str) -> str: + "Handles serialization aliasing and casing" + + # Handle parameters that start with "@" + if field.startswith("at_"): + return f"@{field[3:]}" + + # Handles from field which is a duplicate reserved internal name + if field == "from_": + return "from" + + # All other fields are converted to camelCase + return to_camel(field) + + model_config = ConfigDict( + populate_by_name=True, + serialize_by_alias=True, + validate_by_alias=True, + arbitrary_types_allowed=True, + extra="allow", + alias_generator=AliasGenerator( + validation_alias=validation_alias_generator, serialization_alias=serialization_alias_generator + ), + ) + + +class CardElement(SerializableObject): + """Base class for CardElement.""" + + pass + + +class Action(SerializableObject): + """Base class for Action.""" + + pass + + +class ContainerLayout(SerializableObject): + """Base class for ContainerLayout.""" + + pass + + +ActionStyle = Literal["default", "positive", "destructive"] + +ActionMode = Literal["primary", "secondary"] + +AssociatedInputs = Literal["auto", "none"] + +ImageInsertPosition = Literal["Selection", "Top", "Bottom"] + +FallbackAction = Literal["drop"] + +ContainerStyle = Literal["default", "emphasis", "accent", "good", "attention", "warning"] + +TargetWidth = Literal[ + "VeryNarrow", + "Narrow", + "Standard", + "Wide", + "atLeast:VeryNarrow", + "atMost:VeryNarrow", + "atLeast:Narrow", + "atMost:Narrow", + "atLeast:Standard", + "atMost:Standard", + "atLeast:Wide", + "atMost:Wide", +] + +HorizontalAlignment = Literal["Left", "Center", "Right"] + +VerticalAlignment = Literal["Top", "Center", "Bottom"] + +FlowLayoutItemFit = Literal["Fit", "Fill"] + +Spacing = Literal["None", "ExtraSmall", "Small", "Default", "Medium", "Large", "ExtraLarge", "Padding"] + +FillMode = Literal["Cover", "RepeatHorizontally", "RepeatVertically", "Repeat"] + +Version = Literal["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"] + +TeamsCardWidth = Literal["full"] + +MentionType = Literal["Person", "Tag"] + +ElementHeight = Literal["auto", "stretch"] + +TextSize = Literal["Small", "Default", "Medium", "Large", "ExtraLarge"] + +TextWeight = Literal["Lighter", "Default", "Bolder"] + +TextColor = Literal["Default", "Dark", "Light", "Accent", "Good", "Warning", "Attention"] + +FontType = Literal["Default", "Monospace"] + +StyleEnum = Literal["compact", "expanded", "filtered"] + +ImageStyle = Literal["Default", "Person", "RoundedCorners"] + +Size = Literal["Auto", "Stretch", "Small", "Medium", "Large"] + +InputTextStyle = Literal["Text", "Tel", "Url", "Email", "Password"] + +RatingSize = Literal["Medium", "Large"] + +RatingColor = Literal["Neutral", "Marigold"] + +RatingStyle = Literal["Default", "Compact"] + +IconSize = Literal["xxSmall", "xSmall", "Small", "Standard", "Medium", "Large", "xLarge", "xxLarge"] + +IconStyle = Literal["Regular", "Filled"] + +CarouselPageAnimation = Literal["Slide", "CrossFade", "None"] + +BadgeIconPosition = Literal["Before", "After"] + +BadgeAppearance = Literal["Filled", "Tint"] + +BadgeSize = Literal["Medium", "Large", "ExtraLarge"] + +BadgeShape = Literal["Square", "Rounded", "Circular"] + +BadgeStyle = Literal["Default", "Subtle", "Informative", "Accent", "Good", "Attention", "Warning"] + +ChartColorSet = Literal["categorical", "sequential", "diverging"] + +ChartColor = Literal[ + "good", + "warning", + "attention", + "neutral", + "categoricalRed", + "categoricalPurple", + "categoricalLavender", + "categoricalBlue", + "categoricalLightBlue", + "categoricalTeal", + "categoricalGreen", + "categoricalLime", + "categoricalMarigold", + "sequential1", + "sequential2", + "sequential3", + "sequential4", + "sequential5", + "sequential6", + "sequential7", + "sequential8", + "divergingBlue", + "divergingLightBlue", + "divergingCyan", + "divergingTeal", + "divergingYellow", + "divergingPeach", + "divergingLightRed", + "divergingRed", + "divergingMaroon", + "divergingGray", +] + +HorizontalBarChartDisplayMode = Literal["AbsoluteWithAxis", "AbsoluteNoAxis", "PartToWhole"] + +GaugeChartValueFormat = Literal["Percentage", "Fraction"] + +CodeLanguage = Literal[ + "Bash", + "C", + "Cpp", + "CSharp", + "Css", + "Dos", + "Go", + "Graphql", + "Html", + "Java", + "JavaScript", + "Json", + "ObjectiveC", + "Perl", + "Php", + "PlainText", + "PowerShell", + "Python", + "Sql", + "TypeScript", + "VbNet", + "Verilog", + "Vhdl", + "Xml", +] + +FallbackElement = Literal["drop"] + +ImageSize = Literal["Small", "Medium", "Large"] + +SizeEnum = Literal["Small", "Default", "Medium", "Large", "ExtraLarge"] + +ThemeName = Literal["Light", "Dark"] + + +class HostCapabilities(SerializableObject): + """Represents a list of versioned capabilities a host application must support.""" + + +class BackgroundImage(SerializableObject): + """Defines a container's background image and the way it should be rendered.""" + + url: Optional[str] = None + """ The URL (or Base64-encoded Data URI) of the image. Acceptable formats are PNG, JPEG, GIF and SVG. """ + + fill_mode: Optional[FillMode] = None + """ Controls how the image should fill the area. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the image should be aligned if it must be cropped or if using repeat fill mode. """ + + vertical_alignment: Optional[VerticalAlignment] = None + """ Controls how the image should be aligned if it must be cropped or if using repeat fill mode. """ + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_fill_mode(self, value: FillMode) -> Self: + self.fill_mode = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_vertical_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_alignment = value + return self + + +class SubmitActionData(SerializableObject): + """Represents the data of an Action.Submit.""" + + ms_teams: Optional[Dict[str, Any]] = None + """ Defines the optional Teams-specific portion of the action's data. """ + + def with_ms_teams(self, value: Dict[str, Any]) -> Self: + self.ms_teams = value + return self + + +class ExecuteAction(Action): + """Gathers input values, merges them with the data property if specified, and sends them to the Bot via an Invoke activity. The Bot can respond synchronously and return an updated Adaptive Card to be displayed by the client. Action.Execute works in all Adaptive Card hosts.""" + + type: Literal["Action.Execute"] = "Action.Execute" + """ Must be **Action.Execute**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + data: Optional[Union[str, SubmitActionData]] = None + """ The data to send to the Bot when the action is executed. When expressed as an object, `data` is sent back to the Bot when the action is executed, adorned with the values of the inputs expressed as key/value pairs, where the key is the Id of the input. If `data` is expressed as a string, input values are not sent to the Bot. """ + + associated_inputs: Optional[AssociatedInputs] = None + """ The Ids of the inputs associated with the Action.Submit. When the action is executed, the values of the associated inputs are sent to the Bot. See [Input validation](topic:input-validation) for more details. """ + + conditionally_enabled: Optional[bool] = None + """ Controls if the action is enabled only if at least one required input has been filled by the user. """ + + verb: Optional[str] = None + """ The verb of the action. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_data(self, value: Union[str, SubmitActionData]) -> Self: + self.data = value + return self + + def with_associated_inputs(self, value: AssociatedInputs) -> Self: + self.associated_inputs = value + return self + + def with_conditionally_enabled(self, value: bool) -> Self: + self.conditionally_enabled = value + return self + + def with_verb(self, value: str) -> Self: + self.verb = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class RefreshDefinition(SerializableObject): + """Defines how a card can be refreshed by making a request to the target Bot.""" + + action: Optional[ExecuteAction] = None + """ The Action.Execute action to invoke to refresh the card. """ + + user_ids: Optional[List[str]] = None + """ The list of user Ids for which the card will be automatically refreshed. In Teams, in chats or channels with more than 60 users, the card will automatically refresh only for users specified in the userIds list. Other users will have to manually click on a "refresh" button. In contexts with fewer than 60 users, the card will automatically refresh for all users. """ + + def with_action(self, value: ExecuteAction) -> Self: + self.action = value + return self + + def with_user_ids(self, value: List[str]) -> Self: + self.user_ids = value + return self + + +class AuthCardButton(SerializableObject): + """Defines a button as displayed when prompting a user to authenticate. For more information, refer to the [Bot Framework CardAction type](https://docs.microsoft.com/dotnet/api/microsoft.bot.schema.cardaction).""" + + type: Optional[str] = None + """ Must be **signin**. """ + + title: Optional[str] = None + """ The caption of the button. """ + + image: Optional[str] = None + """ A URL to an image to display alongside the button’s caption. """ + + value: Optional[str] = None + """ The value associated with the button. The meaning of value depends on the button’s type. """ + + def with_type(self, value: str) -> Self: + self.type = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_image(self, value: str) -> Self: + self.image = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class TokenExchangeResource(SerializableObject): + """Defines information required to enable on-behalf-of single sign-on user authentication. For more information, refer to the [Bot Framework TokenExchangeResource type](https://docs.microsoft.com/dotnet/api/microsoft.bot.schema.tokenexchangeresource)""" + + id: Optional[str] = None + """ The unique identified of this token exchange instance. """ + + uri: Optional[str] = None + """ An application ID or resource identifier with which to exchange a token on behalf of. This property is identity provider- and application-specific. """ + + provider_id: Optional[str] = None + """ An identifier for the identity provider with which to attempt a token exchange. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_uri(self, value: str) -> Self: + self.uri = value + return self + + def with_provider_id(self, value: str) -> Self: + self.provider_id = value + return self + + +class Authentication(SerializableObject): + """Defines authentication information associated with a card. For more information, refer to the [Bot Framework OAuthCard type](https://docs.microsoft.com/dotnet/api/microsoft.bot.schema.oauthcard)""" + + text: Optional[str] = None + """ The text that can be displayed to the end user when prompting them to authenticate. """ + + connection_name: Optional[str] = None + """ The identifier for registered OAuth connection setting information. """ + + buttons: Optional[List[AuthCardButton]] = None + """ The buttons that should be displayed to the user when prompting for authentication. The array MUST contain one button of type “signin”. Other button types are not currently supported. """ + + token_exchange_resource: Optional[TokenExchangeResource] = None + """ Provides information required to enable on-behalf-of single sign-on user authentication. """ + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_connection_name(self, value: str) -> Self: + self.connection_name = value + return self + + def with_buttons(self, value: List[AuthCardButton]) -> Self: + self.buttons = value + return self + + def with_token_exchange_resource(self, value: TokenExchangeResource) -> Self: + self.token_exchange_resource = value + return self + + +class MentionedEntity(SerializableObject): + """Represents a mentioned person or tag.""" + + id: Optional[str] = None + """ The Id of a person (typically a Microsoft Entra user Id) or tag. """ + + name: Optional[str] = None + """ The name of the mentioned entity. """ + + mention_type: Optional[MentionType] = None + """ The type of the mentioned entity. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_mention_type(self, value: MentionType) -> Self: + self.mention_type = value + return self + + +class Mention(SerializableObject): + """Represents a mention to a person.""" + + type: Literal["mention"] = "mention" + """ Must be **mention**. """ + + text: Optional[str] = None + """ The text that will be substituted with the mention. """ + + mentioned: Optional[MentionedEntity] = None + """ Defines the entity being mentioned. """ + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_mentioned(self, value: MentionedEntity) -> Self: + self.mentioned = value + return self + + +class TeamsCardProperties(SerializableObject): + """Represents a set of Teams-specific properties on a card.""" + + width: Optional[TeamsCardWidth] = None + """ Controls the width of the card in a Teams chat. + +Note that setting `width` to "full" will not actually stretch the card to the "full width" of the chat pane. It will only make the card wider than when the `width` property isn't set. """ + + entities: Optional[List[Mention]] = None + """ The Teams-specific entities associated with the card. """ + + def with_width(self, value: TeamsCardWidth) -> Self: + self.width = value + return self + + def with_entities(self, value: List[Mention]) -> Self: + self.entities = value + return self + + +class CardMetadata(SerializableObject): + """Card-level metadata.""" + + web_url: Optional[str] = None + """ The URL the card originates from. When `webUrl` is set, the card is dubbed an **Adaptive Card-based Loop Component** and, when pasted in Teams or other Loop Component-capable host applications, the URL will unfurl to the same exact card. """ + + def with_web_url(self, value: str) -> Self: + self.web_url = value + return self + + +class AdaptiveCard(CardElement): + """An Adaptive Card, containing a free-form body of card elements, and an optional set of actions.""" + + type: Literal["AdaptiveCard"] = "AdaptiveCard" + """ Must be **AdaptiveCard**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + layouts: Optional[List[ContainerLayout]] = None + """ The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See [Container layouts](topic:container-layouts) for more details. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + background_image: Optional[Union[str, BackgroundImage]] = None + """ Defines the container's background image. """ + + vertical_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the container's content should be vertically aligned. """ + + rtl: Optional[bool] = None + """ Controls if the content of the card is to be rendered left-to-right or right-to-left. """ + + ac_schema: Optional[str] = Field(None, alias="schema") + """ A URL to the Adaptive Card schema the card is authored against. """ + + version: Optional[Version] = None + """ The Adaptive Card schema version the card is authored against. """ + + fallback_text: Optional[str] = None + """ The text that should be displayed if the client is not able to render the card. """ + + speak: Optional[str] = None + """ The text that should be spoken for the entire card. """ + + refresh: Optional[RefreshDefinition] = None + """ Defines how the card can be refreshed by making a request to the target Bot. """ + + authentication: Optional[Authentication] = None + """ Defines authentication information to enable on-behalf-of single-sign-on or just-in-time OAuth. This information is used in conjunction with the refresh property and Action.Execute in general. """ + + ms_teams: Optional[TeamsCardProperties] = None + """ Teams-specific metadata associated with the card. """ + + metadata: Optional[CardMetadata] = None + """ Metadata associated with the card. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + body: Optional[List[CardElement]] = None + """ The body of the card, comprised of a list of elements displayed according to the layouts property. If the layouts property is not specified, a Layout.Stack is used. """ + + actions: Optional[List[Action]] = None + """ The card level actions, which always appear at the bottom of the card. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_layouts(self, value: List[ContainerLayout]) -> Self: + self.layouts = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_background_image(self, value: Union[str, BackgroundImage]) -> Self: + self.background_image = value + return self + + def with_vertical_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_content_alignment = value + return self + + def with_rtl(self, value: bool) -> Self: + self.rtl = value + return self + + def withac_schema(self, value: str) -> Self: + self.ac_schema = value + return self + + def with_version(self, value: Version) -> Self: + self.version = value + return self + + def with_fallback_text(self, value: str) -> Self: + self.fallback_text = value + return self + + def with_speak(self, value: str) -> Self: + self.speak = value + return self + + def with_refresh(self, value: RefreshDefinition) -> Self: + self.refresh = value + return self + + def with_authentication(self, value: Authentication) -> Self: + self.authentication = value + return self + + def with_ms_teams(self, value: TeamsCardProperties) -> Self: + self.ms_teams = value + return self + + def with_metadata(self, value: CardMetadata) -> Self: + self.metadata = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_body(self, value: List[CardElement]) -> Self: + self.body = value + return self + + def with_actions(self, value: List[Action]) -> Self: + self.actions = value + return self + + +class ImBackSubmitActionData(SerializableObject): + """Represents Teams-specific data in an Action.Submit to send an Instant Message back to the Bot.""" + + type: Literal["imBack"] = "imBack" + """ Must be **imBack**. """ + + value: Optional[str] = None + """ The value that will be sent to the Bot. """ + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class InvokeSubmitActionData(SerializableObject): + """Represents Teams-specific data in an Action.Submit to make an Invoke request to the Bot.""" + + type: Literal["invoke"] = "invoke" + """ Must be **invoke**. """ + + value: Optional[Dict[str, Any]] = None + """ The object to send to the Bot with the Invoke request. """ + + def with_value(self, value: Dict[str, Any]) -> Self: + self.value = value + return self + + +class MessageBackSubmitActionData(SerializableObject): + """Represents Teams-specific data in an Action.Submit to send a message back to the Bot.""" + + type: Literal["messageBack"] = "messageBack" + """ Must be **messageBack**. """ + + text: Optional[str] = None + """ The text that will be sent to the Bot. """ + + display_text: Optional[str] = None + """ The optional text that will be displayed as a new message in the conversation, as if the end-user sent it. `displayText` is not sent to the Bot. """ + + value: Optional[str] = None + """ Optional additional value that will be sent to the Bot. For instance, `value` can encode specific context for the action, such as unique identifiers or a JSON object. """ + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_display_text(self, value: str) -> Self: + self.display_text = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class SigninSubmitActionData(SerializableObject): + """Represents Teams-specific data in an Action.Submit to sign in a user.""" + + type: Literal["signin"] = "signin" + """ Must be **signin**. """ + + value: Optional[str] = None + """ The URL to redirect the end-user for signing in. """ + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class TaskFetchSubmitActionData(SerializableObject): + """Represents Teams-specific data in an Action.Submit to open a task module.""" + + type: Literal["task/fetch"] = "task/fetch" + """ Must be **task/fetch**. """ + + value: Optional[Dict[str, Any]] = None + """ The contextual data sent to the Bot to specify which task module to open. """ + + def with_value(self, value: Dict[str, Any]) -> Self: + self.value = value + return self + + +class TeamsSubmitActionFeedback(SerializableObject): + """Represents feedback options for an [Action.Submit](https://adaptivecards.microsoft.com/?topic=Action.Submit).""" + + hide: Optional[bool] = None + """ Defines if a feedback message should be displayed after the action is executed. """ + + def with_hide(self, value: bool) -> Self: + self.hide = value + return self + + +class TeamsSubmitActionProperties(SerializableObject): + """Teams-specific properties associated with the action.""" + + feedback: Optional[TeamsSubmitActionFeedback] = None + """ Defines how feedback is provided to the end-user when the action is executed. """ + + def with_feedback(self, value: TeamsSubmitActionFeedback) -> Self: + self.feedback = value + return self + + +class SubmitAction(Action): + """Gathers input values, merges them with the data property if specified, and sends them to the Bot via an Invoke activity. The Bot can only acknowledge is has received the request.""" + + type: Literal["Action.Submit"] = "Action.Submit" + """ Must be **Action.Submit**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + data: Optional[Union[str, SubmitActionData]] = None + """ The data to send to the Bot when the action is executed. When expressed as an object, `data` is sent back to the Bot when the action is executed, adorned with the values of the inputs expressed as key/value pairs, where the key is the Id of the input. If `data` is expressed as a string, input values are not sent to the Bot. """ + + associated_inputs: Optional[AssociatedInputs] = None + """ The Ids of the inputs associated with the Action.Submit. When the action is executed, the values of the associated inputs are sent to the Bot. See [Input validation](topic:input-validation) for more details. """ + + conditionally_enabled: Optional[bool] = None + """ Controls if the action is enabled only if at least one required input has been filled by the user. """ + + ms_teams: Optional[TeamsSubmitActionProperties] = None + """ Teams-specific metadata associated with the action. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_data(self, value: Union[str, SubmitActionData]) -> Self: + self.data = value + return self + + def with_associated_inputs(self, value: AssociatedInputs) -> Self: + self.associated_inputs = value + return self + + def with_conditionally_enabled(self, value: bool) -> Self: + self.conditionally_enabled = value + return self + + def with_ms_teams(self, value: TeamsSubmitActionProperties) -> Self: + self.ms_teams = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class OpenUrlAction(Action): + """Opens the provided URL in either a separate browser tab or within the host application.""" + + type: Literal["Action.OpenUrl"] = "Action.OpenUrl" + """ Must be **Action.OpenUrl**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + url: Optional[str] = None + """ The URL to open. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class TargetElement(SerializableObject): + """Defines a target element in an Action.ToggleVisibility.""" + + element_id: Optional[str] = None + """ The Id of the element to change the visibility of. """ + + is_visible: Optional[bool] = None + """ The new visibility state of the element. """ + + def with_element_id(self, value: str) -> Self: + self.element_id = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + +class ToggleVisibilityAction(Action): + """Toggles the visibility of a set of elements. Action.ToggleVisibility is useful for creating "Show more" type UI patterns.""" + + type: Literal["Action.ToggleVisibility"] = "Action.ToggleVisibility" + """ Must be **Action.ToggleVisibility**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + target_elements: Optional[Union[List[str], List[TargetElement]]] = None + """ The Ids of the elements to toggle the visibility of. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_target_elements(self, value: Union[List[str], List[TargetElement]]) -> Self: + self.target_elements = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class ShowCardAction(Action): + """Expands or collapses an embedded card within the main card.""" + + type: Literal["Action.ShowCard"] = "Action.ShowCard" + """ Must be **Action.ShowCard**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + card: Optional[AdaptiveCard] = None + """ The card that should be displayed when the action is executed. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + def with_card(self, value: AdaptiveCard) -> Self: + self.card = value + return self + + +class ResetInputsAction(Action): + """Resets the values of the inputs in the card.""" + + type: Literal["Action.ResetInputs"] = "Action.ResetInputs" + """ Must be **Action.ResetInputs**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + target_input_ids: Optional[List[str]] = None + """ The Ids of the inputs that should be reset. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_target_input_ids(self, value: List[str]) -> Self: + self.target_input_ids = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class InsertImageAction(Action): + """Inserts an image into the host application's canvas.""" + + type: Literal["Action.InsertImage"] = "Action.InsertImage" + """ Must be **Action.InsertImage**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + title: Optional[str] = None + """ The title of the action, as it appears on buttons. """ + + icon_url: Optional[str] = None + """ A URL (or Base64-encoded Data URI) to a PNG, GIF, JPEG or SVG image to be displayed on the left of the action's title. + +`iconUrl` also accepts the `[,regular|filled]` format to display an icon from the vast [Adaptive Card icon catalog](topic:icon-catalog) instead of an image. """ + + style: Optional[ActionStyle] = None + """ Control the style of the action, affecting its visual and spoken representations. """ + + mode: Optional[ActionMode] = None + """ Controls if the action is primary or secondary. Secondary actions appear in an overflow menu. """ + + tooltip: Optional[str] = None + """ The tooltip text to display when the action is hovered over. """ + + is_enabled: Optional[bool] = True + """ Controls the enabled state of the action. A disabled action cannot be clicked. If the action is represented as a button, the button's style will reflect this state. """ + + url: Optional[str] = None + """ The URL of the image to insert. """ + + alt_text: Optional[str] = None + """ The alternate text for the image. """ + + insert_position: Optional[ImageInsertPosition] = None + """ The position at which to insert the image. """ + + fallback: Optional[Union[Action, FallbackAction]] = None + """ An alternate action to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_icon_url(self, value: str) -> Self: + self.icon_url = value + return self + + def with_style(self, value: ActionStyle) -> Self: + self.style = value + return self + + def with_mode(self, value: ActionMode) -> Self: + self.mode = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_is_enabled(self, value: bool) -> Self: + self.is_enabled = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_alt_text(self, value: str) -> Self: + self.alt_text = value + return self + + def with_insert_position(self, value: ImageInsertPosition) -> Self: + self.insert_position = value + return self + + def with_fallback(self, value: Union[Action, FallbackAction]) -> Self: + self.fallback = value + return self + + +class StackLayout(ContainerLayout): + """A layout that stacks elements on top of each other. Layout.Stack is the default layout used by AdaptiveCard and all containers.""" + + type: Literal["Layout.Stack"] = "Layout.Stack" + """ Must be **Layout.Stack**. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the layout should be used. """ + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + +class FlowLayout(ContainerLayout): + """A layout that spreads elements horizontally and wraps them across multiple rows, as needed.""" + + type: Literal["Layout.Flow"] = "Layout.Flow" + """ Must be **Layout.Flow**. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the layout should be used. """ + + horizontal_items_alignment: Optional[HorizontalAlignment] = None + """ Controls how the content of the container should be horizontally aligned. """ + + vertical_items_alignment: Optional[VerticalAlignment] = None + """ Controls how the content of the container should be vertically aligned. """ + + item_fit: Optional[FlowLayoutItemFit] = None + """ Controls how item should fit inside the container. """ + + min_item_width: Optional[str] = None + """ The minimum width, in pixels, of each item, in the `px` format. Should not be used if itemWidth is set. """ + + max_item_width: Optional[str] = None + """ The maximum width, in pixels, of each item, in the `px` format. Should not be used if itemWidth is set. """ + + item_width: Optional[str] = None + """ The width, in pixels, of each item, in the `px` format. Should not be used if maxItemWidth and/or minItemWidth are set. """ + + column_spacing: Optional[Spacing] = None + """ The space between items. """ + + row_spacing: Optional[Spacing] = None + """ The space between rows of items. """ + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_horizontal_items_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_items_alignment = value + return self + + def with_vertical_items_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_items_alignment = value + return self + + def with_item_fit(self, value: FlowLayoutItemFit) -> Self: + self.item_fit = value + return self + + def with_min_item_width(self, value: str) -> Self: + self.min_item_width = value + return self + + def with_max_item_width(self, value: str) -> Self: + self.max_item_width = value + return self + + def with_item_width(self, value: str) -> Self: + self.item_width = value + return self + + def with_column_spacing(self, value: Spacing) -> Self: + self.column_spacing = value + return self + + def with_row_spacing(self, value: Spacing) -> Self: + self.row_spacing = value + return self + + +class GridArea(SerializableObject): + """Defines an area in a Layout.AreaGrid layout.""" + + name: Optional[str] = None + """ The name of the area. To place an element in this area, set its `grid.area` property to match the name of the area. """ + + column: Optional[float] = 1 + """ The start column index of the area. Column indices start at 1. """ + + column_span: Optional[float] = 1 + """ Defines how many columns the area should span. """ + + row: Optional[float] = 1 + """ The start row index of the area. Row indices start at 1. """ + + row_span: Optional[float] = 1 + """ Defines how many rows the area should span. """ + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_column(self, value: float) -> Self: + self.column = value + return self + + def with_column_span(self, value: float) -> Self: + self.column_span = value + return self + + def with_row(self, value: float) -> Self: + self.row = value + return self + + def with_row_span(self, value: float) -> Self: + self.row_span = value + return self + + +class AreaGridLayout(ContainerLayout): + """A layout that divides a container into named areas into which elements can be placed.""" + + type: Literal["Layout.AreaGrid"] = "Layout.AreaGrid" + """ Must be **Layout.AreaGrid**. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the layout should be used. """ + + columns: Optional[Union[List[float], List[str]]] = None + """ The columns in the grid layout, defined as a percentage of the available width or in pixels using the `px` format. """ + + areas: Optional[List[GridArea]] = None + """ The areas in the grid layout. """ + + column_spacing: Optional[Spacing] = None + """ The space between columns. """ + + row_spacing: Optional[Spacing] = None + """ The space between rows. """ + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_columns(self, value: Union[List[float], List[str]]) -> Self: + self.columns = value + return self + + def with_areas(self, value: List[GridArea]) -> Self: + self.areas = value + return self + + def with_column_spacing(self, value: Spacing) -> Self: + self.column_spacing = value + return self + + def with_row_spacing(self, value: Spacing) -> Self: + self.row_spacing = value + return self + + +class Container(CardElement): + """A container for other elements. Use containers for styling purposes and/or to logically group a set of elements together, which can be especially useful when used with Action.ToggleVisibility.""" + + type: Literal["Container"] = "Container" + """ Must be **Container**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + layouts: Optional[List[ContainerLayout]] = None + """ The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See [Container layouts](topic:container-layouts) for more details. """ + + bleed: Optional[bool] = None + """ Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + background_image: Optional[Union[str, BackgroundImage]] = None + """ Defines the container's background image. """ + + vertical_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the container's content should be vertically aligned. """ + + rtl: Optional[bool] = None + """ Controls if the content of the card is to be rendered left-to-right or right-to-left. """ + + max_height: Optional[str] = None + """ The maximum height, in pixels, of the container, in the `px` format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + items: Optional[List[CardElement]] = None + """ The elements in the container. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_layouts(self, value: List[ContainerLayout]) -> Self: + self.layouts = value + return self + + def with_bleed(self, value: bool) -> Self: + self.bleed = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_background_image(self, value: Union[str, BackgroundImage]) -> Self: + self.background_image = value + return self + + def with_vertical_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_content_alignment = value + return self + + def with_rtl(self, value: bool) -> Self: + self.rtl = value + return self + + def with_max_height(self, value: str) -> Self: + self.max_height = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_items(self, value: List[CardElement]) -> Self: + self.items = value + return self + + +class ActionSet(CardElement): + """Displays a set of action, which can be placed anywhere in the card.""" + + type: Literal["ActionSet"] = "ActionSet" + """ Must be **ActionSet**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + actions: Optional[List[Action]] = None + """ The actions in the set. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_actions(self, value: List[Action]) -> Self: + self.actions = value + return self + + +class Column(CardElement): + """A column in a ColumnSet element.""" + + type: Literal["Column"] = "Column" + """ Optional. If specified, must be **Column**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + layouts: Optional[List[ContainerLayout]] = None + """ The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See [Container layouts](topic:container-layouts) for more details. """ + + bleed: Optional[bool] = None + """ Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + background_image: Optional[Union[str, BackgroundImage]] = None + """ Defines the container's background image. """ + + vertical_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the container's content should be vertically aligned. """ + + rtl: Optional[bool] = None + """ Controls if the content of the card is to be rendered left-to-right or right-to-left. """ + + max_height: Optional[str] = None + """ The maximum height, in pixels, of the container, in the `px` format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed. """ + + width: Optional[Union[str, float]] = "stretch" + """ The width of the column. If expressed as a number, represents the relative weight of the column in the set. If expressed as a string, `auto` will automatically adjust the column's width according to its content, `stretch` will make the column use the remaining horizontal space (shared with other columns with width set to `stretch`) and using the `px` format will give the column an explicit width in pixels. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + items: Optional[List[CardElement]] = None + """ The elements in the column. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_layouts(self, value: List[ContainerLayout]) -> Self: + self.layouts = value + return self + + def with_bleed(self, value: bool) -> Self: + self.bleed = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_background_image(self, value: Union[str, BackgroundImage]) -> Self: + self.background_image = value + return self + + def with_vertical_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_content_alignment = value + return self + + def with_rtl(self, value: bool) -> Self: + self.rtl = value + return self + + def with_max_height(self, value: str) -> Self: + self.max_height = value + return self + + def with_width(self, value: Union[str, float]) -> Self: + self.width = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_items(self, value: List[CardElement]) -> Self: + self.items = value + return self + + +class ColumnSet(CardElement): + """Splits the available horizontal space into separate columns, so elements can be organized in a row.""" + + type: Literal["ColumnSet"] = "ColumnSet" + """ Must be **ColumnSet**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + bleed: Optional[bool] = None + """ Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + columns: Optional[List[Column]] = None + """ The columns in the set. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_bleed(self, value: bool) -> Self: + self.bleed = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_columns(self, value: List[Column]) -> Self: + self.columns = value + return self + + +class MediaSource(SerializableObject): + """Defines the source URL of a media stream. YouTube, Dailymotion, Vimeo and Microsoft Stream URLs are supported.""" + + mime_type: Optional[str] = None + """ The MIME type of the source. """ + + url: Optional[str] = None + """ The URL of the source. """ + + def with_mime_type(self, value: str) -> Self: + self.mime_type = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + +class CaptionSource(SerializableObject): + """Defines a source URL for a video captions.""" + + mime_type: Optional[str] = None + """ The MIME type of the source. """ + + url: Optional[str] = None + """ The URL of the source. """ + + label: Optional[str] = None + """ The label of this caption source. """ + + def with_mime_type(self, value: str) -> Self: + self.mime_type = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + +class Media(CardElement): + """A media element, that makes it possible to embed videos inside a card.""" + + type: Literal["Media"] = "Media" + """ Must be **Media**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + sources: Optional[List[MediaSource]] = None + """ The sources for the media. For YouTube, Dailymotion and Vimeo, only one source can be specified. """ + + caption_sources: Optional[List[CaptionSource]] = None + """ The caption sources for the media. Caption sources are not used for YouTube, Dailymotion or Vimeo sources. """ + + poster: Optional[str] = None + """ The URL of the poster image to display. """ + + alt_text: Optional[str] = None + """ The alternate text for the media, used for accessibility purposes. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_sources(self, value: List[MediaSource]) -> Self: + self.sources = value + return self + + def with_caption_sources(self, value: List[CaptionSource]) -> Self: + self.caption_sources = value + return self + + def with_poster(self, value: str) -> Self: + self.poster = value + return self + + def with_alt_text(self, value: str) -> Self: + self.alt_text = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class RichTextBlock(CardElement): + """A rich text block that displays formatted text.""" + + type: Literal["RichTextBlock"] = "RichTextBlock" + """ Must be **RichTextBlock**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + inlines: Optional[Union[List[CardElement], List[str]]] = None + """ The inlines making up the rich text block. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_inlines(self, value: Union[List[CardElement], List[str]]) -> Self: + self.inlines = value + return self + + +class ColumnDefinition(SerializableObject): + """Defines a column in a Table element.""" + + horizontal_cell_content_alignment: Optional[HorizontalAlignment] = None + """ Controls how the content of every cell in the table should be horizontally aligned by default. This property overrides the horizontalCellContentAlignment property of the table. """ + + vertical_cell_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the content of every cell in the column should be vertically aligned by default. This property overrides the verticalCellContentAlignment property of the table. """ + + width: Optional[Union[str, float]] = None + """ The width of the column in the table, expressed as either a percentage of the available width or in pixels, using the `px` format. """ + + def with_horizontal_cell_content_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_cell_content_alignment = value + return self + + def with_vertical_cell_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_cell_content_alignment = value + return self + + def with_width(self, value: Union[str, float]) -> Self: + self.width = value + return self + + +class TableCell(CardElement): + """Represents a cell in a table row.""" + + type: Literal["TableCell"] = "TableCell" + """ Must be **TableCell**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + layouts: Optional[List[ContainerLayout]] = None + """ The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See [Container layouts](topic:container-layouts) for more details. """ + + bleed: Optional[bool] = None + """ Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + background_image: Optional[Union[str, BackgroundImage]] = None + """ Defines the container's background image. """ + + vertical_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the container's content should be vertically aligned. """ + + rtl: Optional[bool] = None + """ Controls if the content of the card is to be rendered left-to-right or right-to-left. """ + + max_height: Optional[str] = None + """ The maximum height, in pixels, of the container, in the `px` format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + items: Optional[List[CardElement]] = None + """ The items (elements) in the cell. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_layouts(self, value: List[ContainerLayout]) -> Self: + self.layouts = value + return self + + def with_bleed(self, value: bool) -> Self: + self.bleed = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_background_image(self, value: Union[str, BackgroundImage]) -> Self: + self.background_image = value + return self + + def with_vertical_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_content_alignment = value + return self + + def with_rtl(self, value: bool) -> Self: + self.rtl = value + return self + + def with_max_height(self, value: str) -> Self: + self.max_height = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_items(self, value: List[CardElement]) -> Self: + self.items = value + return self + + +class TableRow(CardElement): + """Represents a row of cells in a table.""" + + type: Literal["TableRow"] = "TableRow" + """ Must be **TableRow**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + horizontal_cell_content_alignment: Optional[HorizontalAlignment] = None + """ Controls how the content of every cell in the row should be horizontally aligned by default. This property overrides the horizontalCellContentAlignment property of the table and columns. """ + + vertical_cell_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the content of every cell in the row should be vertically aligned by default. This property overrides the verticalCellContentAlignment property of the table and columns. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + cells: Optional[List[TableCell]] = None + """ The cells in the row. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_horizontal_cell_content_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_cell_content_alignment = value + return self + + def with_vertical_cell_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_cell_content_alignment = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_cells(self, value: List[TableCell]) -> Self: + self.cells = value + return self + + +class Table(CardElement): + """Use tables to display data in a tabular way, with rows, columns and cells.""" + + type: Literal["Table"] = "Table" + """ Must be **Table**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + columns: Optional[List[ColumnDefinition]] = None + """ The columns in the table. """ + + first_row_as_headers: Optional[bool] = True + """ Controls whether the first row of the table should be treated as a header. """ + + show_grid_lines: Optional[bool] = True + """ Controls if grid lines should be displayed. """ + + grid_style: Optional[ContainerStyle] = None + """ The style of the grid lines between cells. """ + + horizontal_cell_content_alignment: Optional[HorizontalAlignment] = None + """ Controls how the content of every cell in the table should be horizontally aligned by default. """ + + vertical_cell_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the content of every cell in the table should be vertically aligned by default. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + rows: Optional[List[TableRow]] = None + """ The rows of the table. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_columns(self, value: List[ColumnDefinition]) -> Self: + self.columns = value + return self + + def with_first_row_as_headers(self, value: bool) -> Self: + self.first_row_as_headers = value + return self + + def with_show_grid_lines(self, value: bool) -> Self: + self.show_grid_lines = value + return self + + def with_grid_style(self, value: ContainerStyle) -> Self: + self.grid_style = value + return self + + def with_horizontal_cell_content_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_cell_content_alignment = value + return self + + def with_vertical_cell_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_cell_content_alignment = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_rows(self, value: List[TableRow]) -> Self: + self.rows = value + return self + + +class TextBlock(CardElement): + """A block of text, optionally formatted using Markdown.""" + + type: Literal["TextBlock"] = "TextBlock" + """ Must be **TextBlock**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + text: Optional[str] = None + """ The text to display. A subset of markdown is supported. """ + + size: Optional[TextSize] = None + """ The size of the text. """ + + weight: Optional[TextWeight] = None + """ The weight of the text. """ + + color: Optional[TextColor] = None + """ The color of the text. """ + + is_subtle: Optional[bool] = None + """ Controls whether the text should be renderer using a subtler variant of the select color. """ + + font_type: Optional[FontType] = None + """ The type of font to use for rendering. """ + + wrap: Optional[bool] = None + """ Controls if the text should wrap. """ + + max_lines: Optional[float] = None + """ The maximum number of lines to display. """ + + style: Optional[StyleEnum] = None + """ The style of the text. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_size(self, value: TextSize) -> Self: + self.size = value + return self + + def with_weight(self, value: TextWeight) -> Self: + self.weight = value + return self + + def with_color(self, value: TextColor) -> Self: + self.color = value + return self + + def with_is_subtle(self, value: bool) -> Self: + self.is_subtle = value + return self + + def with_font_type(self, value: FontType) -> Self: + self.font_type = value + return self + + def with_wrap(self, value: bool) -> Self: + self.wrap = value + return self + + def with_max_lines(self, value: float) -> Self: + self.max_lines = value + return self + + def with_style(self, value: StyleEnum) -> Self: + self.style = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class Fact(SerializableObject): + """A fact in a FactSet element.""" + + title: Optional[str] = None + """ The fact's title. """ + + value: Optional[str] = None + """ The fact's value. """ + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class FactSet(CardElement): + """A set of facts, displayed as a table or a vertical list when horizontal space is constrained.""" + + type: Literal["FactSet"] = "FactSet" + """ Must be **FactSet**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + facts: Optional[List[Fact]] = None + """ The facts in the set. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_facts(self, value: List[Fact]) -> Self: + self.facts = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class TeamsImageProperties(SerializableObject): + """Represents a set of Teams-specific properties on an image.""" + + allow_expand: Optional[bool] = None + """ Controls if the image is expandable in Teams. This property is equivalent to the Image.allowExpand property. """ + + def with_allow_expand(self, value: bool) -> Self: + self.allow_expand = value + return self + + +class Image(CardElement): + """A standalone image element.""" + + type: Literal["Image"] = "Image" + """ Must be **Image**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + url: Optional[str] = None + """ The URL (or Base64-encoded Data URI) of the image. Acceptable formats are PNG, JPEG, GIF and SVG. """ + + alt_text: Optional[str] = None + """ The alternate text for the image, used for accessibility purposes. """ + + background_color: Optional[str] = None + """ The background color of the image. """ + + style: Optional[ImageStyle] = None + """ The style of the image. """ + + size: Optional[Size] = None + """ The size of the image. """ + + width: Optional[str] = "auto" + """ The width of the image. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the image is tapped or clicked. Action.ShowCard is not supported. """ + + allow_expand: Optional[bool] = None + """ Controls if the image can be expanded to full screen. """ + + ms_teams: Optional[TeamsImageProperties] = None + """ Teams-specific metadata associated with the image. """ + + height: Optional[str] = "auto" + """ The height of the image. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_alt_text(self, value: str) -> Self: + self.alt_text = value + return self + + def with_background_color(self, value: str) -> Self: + self.background_color = value + return self + + def with_style(self, value: ImageStyle) -> Self: + self.style = value + return self + + def with_size(self, value: Size) -> Self: + self.size = value + return self + + def with_width(self, value: str) -> Self: + self.width = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_allow_expand(self, value: bool) -> Self: + self.allow_expand = value + return self + + def with_ms_teams(self, value: TeamsImageProperties) -> Self: + self.ms_teams = value + return self + + def with_height(self, value: str) -> Self: + self.height = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class ImageSet(CardElement): + """A set of images, displayed side-by-side and wrapped across multiple rows as needed.""" + + type: Literal["ImageSet"] = "ImageSet" + """ Must be **ImageSet**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + images: Optional[List[Image]] = None + """ The images in the set. """ + + image_size: Optional[ImageSize] = None + """ The size to use to render all images in the set. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_images(self, value: List[Image]) -> Self: + self.images = value + return self + + def with_image_size(self, value: ImageSize) -> Self: + self.image_size = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class TextInput(CardElement): + """An input to allow the user to enter text.""" + + type: Literal["Input.Text"] = "Input.Text" + """ Must be **Input.Text**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[str] = None + """ The default value of the input. """ + + max_length: Optional[float] = None + """ The maximum length of the text in the input. """ + + is_multiline: Optional[bool] = None + """ Controls if the input should allow multiple lines of text. """ + + placeholder: Optional[str] = None + """ The text to display as a placeholder when the user hasn't entered a value. """ + + style: Optional[InputTextStyle] = None + """ The style of the input. """ + + inline_action: Optional[Action] = None + """ The action that should be displayed as a button alongside the input. Action.ShowCard is not supported. """ + + regex: Optional[str] = None + """ The regular expression to validate the input. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + def with_max_length(self, value: float) -> Self: + self.max_length = value + return self + + def with_is_multiline(self, value: bool) -> Self: + self.is_multiline = value + return self + + def with_placeholder(self, value: str) -> Self: + self.placeholder = value + return self + + def with_style(self, value: InputTextStyle) -> Self: + self.style = value + return self + + def with_inline_action(self, value: Action) -> Self: + self.inline_action = value + return self + + def with_regex(self, value: str) -> Self: + self.regex = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class DateInput(CardElement): + """An input to allow the user to select a date.""" + + type: Literal["Input.Date"] = "Input.Date" + """ Must be **Input.Date**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[str] = None + """ The default value of the input, in the `YYYY-MM-DD` format. """ + + placeholder: Optional[str] = None + """ The text to display as a placeholder when the user has not selected a date. """ + + min: Optional[str] = None + """ The minimum date that can be selected. """ + + max: Optional[str] = None + """ The maximum date that can be selected. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + def with_placeholder(self, value: str) -> Self: + self.placeholder = value + return self + + def with_min(self, value: str) -> Self: + self.min = value + return self + + def with_max(self, value: str) -> Self: + self.max = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class TimeInput(CardElement): + """An input to allow the user to select a time.""" + + type: Literal["Input.Time"] = "Input.Time" + """ Must be **Input.Time**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[str] = None + """ The default value of the input, in the `HH:MM` format. """ + + placeholder: Optional[str] = None + """ The text to display as a placeholder when the user hasn't entered a value. """ + + min: Optional[str] = None + """ The minimum time that can be selected, in the `HH:MM` format. """ + + max: Optional[str] = None + """ The maximum time that can be selected, in the `HH:MM` format. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + def with_placeholder(self, value: str) -> Self: + self.placeholder = value + return self + + def with_min(self, value: str) -> Self: + self.min = value + return self + + def with_max(self, value: str) -> Self: + self.max = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class NumberInput(CardElement): + """An input to allow the user to enter a number.""" + + type: Literal["Input.Number"] = "Input.Number" + """ Must be **Input.Number**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[float] = None + """ The default value of the input. """ + + placeholder: Optional[str] = None + """ The text to display as a placeholder when the user hasn't entered a value. """ + + min: Optional[float] = None + """ The minimum value that can be entered. """ + + max: Optional[float] = None + """ The maximum value that can be entered. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_placeholder(self, value: str) -> Self: + self.placeholder = value + return self + + def with_min(self, value: float) -> Self: + self.min = value + return self + + def with_max(self, value: float) -> Self: + self.max = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class ToggleInput(CardElement): + """An input to allow the user to select between on/off states.""" + + type: Literal["Input.Toggle"] = "Input.Toggle" + """ Must be **Input.Toggle**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[str] = "false" + """ The default value of the input. """ + + title: Optional[str] = None + """ The title (caption) to display next to the toggle. """ + + value_on: Optional[str] = "true" + """ The value to send to the Bot when the toggle is on. """ + + value_off: Optional[str] = "false" + """ The value to send to the Bot when the toggle is off. """ + + wrap: Optional[bool] = True + """ Controls if the title should wrap. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_value_on(self, value: str) -> Self: + self.value_on = value + return self + + def with_value_off(self, value: str) -> Self: + self.value_off = value + return self + + def with_wrap(self, value: bool) -> Self: + self.wrap = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class Choice(SerializableObject): + """A choice as used by the Input.ChoiceSet input.""" + + title: Optional[str] = None + """ The text to display for the choice. """ + + value: Optional[str] = None + """ The value associated with the choice, as sent to the Bot when an Action.Submit or Action.Execute is invoked """ + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + +class QueryData(SerializableObject): + """Defines a query to dynamically fetch data from a Bot.""" + + type: Literal["Data.Query"] = "Data.Query" + """ Must be **Data.Query**. """ + + dataset: Optional[str] = None + """ The dataset from which to fetch the data. """ + + associated_inputs: Optional[AssociatedInputs] = None + """ Controls which inputs are associated with the Data.Query. When a Data.Query is executed, the values of the associated inputs are sent to the Bot, allowing it to perform filtering operations based on the user's input. """ + + count: Optional[float] = None + """ The maximum number of data items that should be returned by the query. Card authors should not specify this property in their card payload. It is determined by the client and sent to the Bot to enable pagination. """ + + skip: Optional[float] = None + """ The number of data items to be skipped by the query. Card authors should not specify this property in their card payload. It is determined by the client and sent to the Bot to enable pagination. """ + + def with_dataset(self, value: str) -> Self: + self.dataset = value + return self + + def with_associated_inputs(self, value: AssociatedInputs) -> Self: + self.associated_inputs = value + return self + + def with_count(self, value: float) -> Self: + self.count = value + return self + + def with_skip(self, value: float) -> Self: + self.skip = value + return self + + +class ChoiceSetInput(CardElement): + """An input to allow the user to select one or more values.""" + + type: Literal["Input.ChoiceSet"] = "Input.ChoiceSet" + """ Must be **Input.ChoiceSet**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[str] = None + """ The default value of the input. """ + + choices: Optional[List[Choice]] = None + """ The choices associated with the input. """ + + choices_data: Optional[QueryData] = None + """ A Data.Query object that defines the dataset from which to dynamically fetch the choices for the input. """ + + style: Optional[StyleEnum] = None + """ Controls whether the input should be displayed as a dropdown (compact) or a list of radio buttons or checkboxes (expanded). """ + + is_multi_select: Optional[bool] = None + """ Controls whether multiple choices can be selected. """ + + placeholder: Optional[str] = None + """ The text to display as a placeholder when the user has not entered any value. """ + + wrap: Optional[bool] = True + """ Controls if choice titles should wrap. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: str) -> Self: + self.value = value + return self + + def with_choices(self, value: List[Choice]) -> Self: + self.choices = value + return self + + def with_choices_data(self, value: QueryData) -> Self: + self.choices_data = value + return self + + def with_style(self, value: StyleEnum) -> Self: + self.style = value + return self + + def with_is_multi_select(self, value: bool) -> Self: + self.is_multi_select = value + return self + + def with_placeholder(self, value: str) -> Self: + self.placeholder = value + return self + + def with_wrap(self, value: bool) -> Self: + self.wrap = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class RatingInput(CardElement): + """An input to allow the user to rate something using stars.""" + + type: Literal["Input.Rating"] = "Input.Rating" + """ Must be **Input.Rating**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + label: Optional[str] = None + """ The label of the input. + +A label should **always** be provided to ensure the best user experience especially for users of assistive technology. """ + + is_required: Optional[bool] = None + """ Controls whether the input is required. See [Input validation](topic:input-validation) for more details. """ + + error_message: Optional[str] = None + """ The error message to display when the input fails validation. See [Input validation](topic:input-validation) for more details. """ + + value_changed_action: Optional[ResetInputsAction] = None + """ An Action.ResetInputs action that will be executed when the value of the input changes. """ + + value: Optional[float] = None + """ The default value of the input. """ + + max: Optional[float] = 5 + """ The number of stars to display. """ + + allow_half_steps: Optional[bool] = None + """ Controls if the user can select half stars. """ + + size: Optional[RatingSize] = None + """ The size of the stars. """ + + color: Optional[RatingColor] = None + """ The color of the stars. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_label(self, value: str) -> Self: + self.label = value + return self + + def with_is_required(self, value: bool) -> Self: + self.is_required = value + return self + + def with_error_message(self, value: str) -> Self: + self.error_message = value + return self + + def with_value_changed_action(self, value: ResetInputsAction) -> Self: + self.value_changed_action = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_max(self, value: float) -> Self: + self.max = value + return self + + def with_allow_half_steps(self, value: bool) -> Self: + self.allow_half_steps = value + return self + + def with_size(self, value: RatingSize) -> Self: + self.size = value + return self + + def with_color(self, value: RatingColor) -> Self: + self.color = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class Rating(CardElement): + """A read-only star rating element, to display the rating of something.""" + + type: Literal["Rating"] = "Rating" + """ Must be **Rating**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + value: Optional[float] = None + """ The value of the rating. Must be between 0 and max. """ + + count: Optional[float] = None + """ The number of "votes" associated with the rating. """ + + max: Optional[float] = 5 + """ The number of stars to display. """ + + size: Optional[RatingSize] = None + """ The size of the stars. """ + + color: Optional[RatingColor] = None + """ The color of the stars. """ + + style: Optional[RatingStyle] = None + """ The style of the stars. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_count(self, value: float) -> Self: + self.count = value + return self + + def with_max(self, value: float) -> Self: + self.max = value + return self + + def with_size(self, value: RatingSize) -> Self: + self.size = value + return self + + def with_color(self, value: RatingColor) -> Self: + self.color = value + return self + + def with_style(self, value: RatingStyle) -> Self: + self.style = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class IconInfo(SerializableObject): + """Defines information about a Fluent icon and how it should be rendered.""" + + name: Optional[str] = None + """ The name of the icon to display. """ + + size: Optional[IconSize] = None + """ The size of the icon. """ + + style: Optional[IconStyle] = None + """ The style of the icon. """ + + color: Optional[TextColor] = None + """ The color of the icon. """ + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_size(self, value: IconSize) -> Self: + self.size = value + return self + + def with_style(self, value: IconStyle) -> Self: + self.style = value + return self + + def with_color(self, value: TextColor) -> Self: + self.color = value + return self + + +class CompoundButton(CardElement): + """A special type of button with an icon, title and description.""" + + type: Literal["CompoundButton"] = "CompoundButton" + """ Must be **CompoundButton**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + icon: Optional[IconInfo] = None + """ The icon to show on the button. """ + + badge: Optional[str] = None + """ The badge to show on the button. """ + + title: Optional[str] = None + """ The title of the button. """ + + description: Optional[str] = None + """ The description text of the button. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the button is tapped or clicked. Action.ShowCard is not supported. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_icon(self, value: IconInfo) -> Self: + self.icon = value + return self + + def with_badge(self, value: str) -> Self: + self.badge = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_description(self, value: str) -> Self: + self.description = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class Icon(CardElement): + """A standalone icon element. Icons can be picked from the vast [Adaptive Card icon catalog](https://adaptivecards.microsoft.com/?topic=icon-catalog).""" + + type: Literal["Icon"] = "Icon" + """ Must be **Icon**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Optional[str] = None + """ The name of the icon to display. """ + + size: Optional[IconSize] = None + """ The size of the icon. """ + + style: Optional[IconStyle] = None + """ The style of the icon. """ + + color: Optional[TextColor] = None + """ The color of the icon. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the icon is tapped or clicked. Action.ShowCard is not supported. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_size(self, value: IconSize) -> Self: + self.size = value + return self + + def with_style(self, value: IconStyle) -> Self: + self.style = value + return self + + def with_color(self, value: TextColor) -> Self: + self.color = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class CarouselPage(CardElement): + """A page inside a Carousel element.""" + + type: Literal["CarouselPage"] = "CarouselPage" + """ Must be **CarouselPage**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the element is tapped or clicked. Action.ShowCard is not supported. """ + + style: Optional[ContainerStyle] = None + """ The style of the container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met. """ + + show_border: Optional[bool] = None + """ Controls if a border should be displayed around the container. """ + + rounded_corners: Optional[bool] = None + """ Controls if the container should have rounded corners. """ + + layouts: Optional[List[ContainerLayout]] = None + """ The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See [Container layouts](topic:container-layouts) for more details. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + background_image: Optional[Union[str, BackgroundImage]] = None + """ Defines the container's background image. """ + + vertical_content_alignment: Optional[VerticalAlignment] = None + """ Controls how the container's content should be vertically aligned. """ + + rtl: Optional[bool] = None + """ Controls if the content of the card is to be rendered left-to-right or right-to-left. """ + + max_height: Optional[str] = None + """ The maximum height, in pixels, of the container, in the `px` format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + items: Optional[List[CardElement]] = None + """ The elements in the page. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_style(self, value: ContainerStyle) -> Self: + self.style = value + return self + + def with_show_border(self, value: bool) -> Self: + self.show_border = value + return self + + def with_rounded_corners(self, value: bool) -> Self: + self.rounded_corners = value + return self + + def with_layouts(self, value: List[ContainerLayout]) -> Self: + self.layouts = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_background_image(self, value: Union[str, BackgroundImage]) -> Self: + self.background_image = value + return self + + def with_vertical_content_alignment(self, value: VerticalAlignment) -> Self: + self.vertical_content_alignment = value + return self + + def with_rtl(self, value: bool) -> Self: + self.rtl = value + return self + + def with_max_height(self, value: str) -> Self: + self.max_height = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_items(self, value: List[CardElement]) -> Self: + self.items = value + return self + + +class Carousel(CardElement): + """A carousel with sliding pages.""" + + type: Literal["Carousel"] = "Carousel" + """ Must be **Carousel**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + bleed: Optional[bool] = None + """ Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding. """ + + min_height: Optional[str] = None + """ The minimum height, in pixels, of the container, in the `px` format. """ + + page_animation: Optional[CarouselPageAnimation] = None + """ Controls the type of animation to use to navigate between pages. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + pages: Optional[List[CarouselPage]] = None + """ The pages in the carousel. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_bleed(self, value: bool) -> Self: + self.bleed = value + return self + + def with_min_height(self, value: str) -> Self: + self.min_height = value + return self + + def with_page_animation(self, value: CarouselPageAnimation) -> Self: + self.page_animation = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + def with_pages(self, value: List[CarouselPage]) -> Self: + self.pages = value + return self + + +class Badge(CardElement): + """A badge element to show an icon and/or text in a compact form over a colored background.""" + + type: Literal["Badge"] = "Badge" + """ Must be **Badge**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + text: Optional[str] = None + """ The text to display. """ + + icon: Optional[str] = None + """ The name of an icon from the [Adaptive Card icon catalog](topic:icon-catalog) to display, in the `[,regular|filled]` format. If the style is not specified, the regular style is used. """ + + icon_position: Optional[BadgeIconPosition] = None + """ Controls the position of the icon. """ + + appearance: Optional[BadgeAppearance] = None + """ Controls the strength of the background color. """ + + size: Optional[BadgeSize] = None + """ The size of the badge. """ + + shape: Optional[BadgeShape] = None + """ Controls the shape of the badge. """ + + style: Optional[BadgeStyle] = None + """ The style of the badge. """ + + tooltip: Optional[str] = None + """ Controls the tooltip text to display when the badge is hovered over. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_icon(self, value: str) -> Self: + self.icon = value + return self + + def with_icon_position(self, value: BadgeIconPosition) -> Self: + self.icon_position = value + return self + + def with_appearance(self, value: BadgeAppearance) -> Self: + self.appearance = value + return self + + def with_size(self, value: BadgeSize) -> Self: + self.size = value + return self + + def with_shape(self, value: BadgeShape) -> Self: + self.shape = value + return self + + def with_style(self, value: BadgeStyle) -> Self: + self.style = value + return self + + def with_tooltip(self, value: str) -> Self: + self.tooltip = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class DonutChartData(SerializableObject): + """A data point in a Donut chart.""" + + legend: Optional[str] = None + """ The legend of the chart. """ + + value: Optional[float] = None + """ The value associated with the data point. """ + + color: Optional[ChartColor] = None + """ The color to use for the data point. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_legend(self, value: str) -> Self: + self.legend = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class DonutChart(CardElement): + """A donut chart.""" + + type: Literal["Chart.Donut"] = "Chart.Donut" + """ Must be **Chart.Donut**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + data: Optional[List[DonutChartData]] = None + """ The data to display in the chart. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_data(self, value: List[DonutChartData]) -> Self: + self.data = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class PieChart(CardElement): + """A pie chart.""" + + type: Literal["Chart.Pie"] = "Chart.Pie" + """ Must be **Chart.Pie**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + data: Optional[List[DonutChartData]] = None + """ The data to display in the chart. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_data(self, value: List[DonutChartData]) -> Self: + self.data = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class BarChartDataValue(SerializableObject): + """A single data point in a bar chart.""" + + x: Optional[str] = None + """ The x axis value of the data point. """ + + y: Optional[float] = None + """ The y axis value of the data point. """ + + def with_x(self, value: str) -> Self: + self.x = value + return self + + def with_y(self, value: float) -> Self: + self.y = value + return self + + +class GroupedVerticalBarChartData(SerializableObject): + """Represents a series of data points.""" + + legend: Optional[str] = None + """ The legend of the chart. """ + + values: Optional[List[BarChartDataValue]] = None + """ The data points in the series. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points in the series. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_legend(self, value: str) -> Self: + self.legend = value + return self + + def with_values(self, value: List[BarChartDataValue]) -> Self: + self.values = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class GroupedVerticalBarChart(CardElement): + """A grouped vertical bar chart.""" + + type: Literal["Chart.VerticalBar.Grouped"] = "Chart.VerticalBar.Grouped" + """ Must be **Chart.VerticalBar.Grouped**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + x_axis_title: Optional[str] = None + """ The title of the x axis. """ + + y_axis_title: Optional[str] = None + """ The title of the y axis. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points. See [Chart colors reference](topic:chart-colors-reference). """ + + stacked: Optional[bool] = None + """ Controls if bars in the chart should be displayed as stacked instead of grouped. """ + + data: Optional[List[GroupedVerticalBarChartData]] = None + """ The data points in a series. """ + + show_bar_values: Optional[bool] = None + """ Controls if values should be displayed on each bar. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_x_axis_title(self, value: str) -> Self: + self.x_axis_title = value + return self + + def with_y_axis_title(self, value: str) -> Self: + self.y_axis_title = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + def with_stacked(self, value: bool) -> Self: + self.stacked = value + return self + + def with_data(self, value: List[GroupedVerticalBarChartData]) -> Self: + self.data = value + return self + + def with_show_bar_values(self, value: bool) -> Self: + self.show_bar_values = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class VerticalBarChartDataValue(SerializableObject): + """Represents a data point in a vertical bar chart.""" + + x: Optional[Union[str, float]] = None + """ The x axis value of the data point. """ + + y: Optional[float] = None + """ The y axis value of the data point. """ + + color: Optional[ChartColor] = None + """ The color to use for the bar associated with the data point. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_x(self, value: Union[str, float]) -> Self: + self.x = value + return self + + def with_y(self, value: float) -> Self: + self.y = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class VerticalBarChart(CardElement): + """A vertical bar chart.""" + + type: Literal["Chart.VerticalBar"] = "Chart.VerticalBar" + """ Must be **Chart.VerticalBar**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + x_axis_title: Optional[str] = None + """ The title of the x axis. """ + + y_axis_title: Optional[str] = None + """ The title of the y axis. """ + + data: Optional[List[VerticalBarChartDataValue]] = None + """ The data to display in the chart. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points. See [Chart colors reference](topic:chart-colors-reference). """ + + show_bar_values: Optional[bool] = None + """ Controls if the bar values should be displayed. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_x_axis_title(self, value: str) -> Self: + self.x_axis_title = value + return self + + def with_y_axis_title(self, value: str) -> Self: + self.y_axis_title = value + return self + + def with_data(self, value: List[VerticalBarChartDataValue]) -> Self: + self.data = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + def with_show_bar_values(self, value: bool) -> Self: + self.show_bar_values = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class HorizontalBarChartDataValue(SerializableObject): + """Represents a single data point in a horizontal bar chart.""" + + x: Optional[str] = None + """ The x axis value of the data point. """ + + y: Optional[float] = None + """ The y axis value of the data point. """ + + color: Optional[ChartColor] = None + """ The color of the bar associated with the data point. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_x(self, value: str) -> Self: + self.x = value + return self + + def with_y(self, value: float) -> Self: + self.y = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class HorizontalBarChart(CardElement): + """A horizontal bar chart.""" + + type: Literal["Chart.HorizontalBar"] = "Chart.HorizontalBar" + """ Must be **Chart.HorizontalBar**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + x_axis_title: Optional[str] = None + """ The title of the x axis. """ + + y_axis_title: Optional[str] = None + """ The title of the y axis. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points. See [Chart colors reference](topic:chart-colors-reference). """ + + data: Optional[List[HorizontalBarChartDataValue]] = None + """ The data points in the chart. """ + + display_mode: Optional[HorizontalBarChartDisplayMode] = None + """ Controls how the chart should be visually laid out. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_x_axis_title(self, value: str) -> Self: + self.x_axis_title = value + return self + + def with_y_axis_title(self, value: str) -> Self: + self.y_axis_title = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + def with_data(self, value: List[HorizontalBarChartDataValue]) -> Self: + self.data = value + return self + + def with_display_mode(self, value: HorizontalBarChartDisplayMode) -> Self: + self.display_mode = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class StackedHorizontalBarChartDataPoint(SerializableObject): + """A data point in a series.""" + + legend: Optional[str] = None + """ The legend associated with the data point. """ + + value: Optional[float] = None + """ The value of the data point. """ + + color: Optional[ChartColor] = None + """ The color to use to render the bar associated with the data point. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_legend(self, value: str) -> Self: + self.legend = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class StackedHorizontalBarChartData(SerializableObject): + """Defines the collection of data series to display in as a stacked horizontal bar chart.""" + + title: Optional[str] = None + """ The title of the series. """ + + data: Optional[List[StackedHorizontalBarChartDataPoint]] = None + """ The data points in the series. """ + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_data(self, value: List[StackedHorizontalBarChartDataPoint]) -> Self: + self.data = value + return self + + +class StackedHorizontalBarChart(CardElement): + """A stacked horizontal bar chart.""" + + type: Literal["Chart.HorizontalBar.Stacked"] = "Chart.HorizontalBar.Stacked" + """ Must be **Chart.HorizontalBar.Stacked**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + x_axis_title: Optional[str] = None + """ The title of the x axis. """ + + y_axis_title: Optional[str] = None + """ The title of the y axis. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points. See [Chart colors reference](topic:chart-colors-reference). """ + + data: Optional[List[StackedHorizontalBarChartData]] = None + """ The data to display in the chart. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_x_axis_title(self, value: str) -> Self: + self.x_axis_title = value + return self + + def with_y_axis_title(self, value: str) -> Self: + self.y_axis_title = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + def with_data(self, value: List[StackedHorizontalBarChartData]) -> Self: + self.data = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class LineChartValue(SerializableObject): + """Represents a single data point in a line chart.""" + + x: Optional[Union[float, str]] = None + """ The x axis value of the data point. + +If all x values of the x [Chart.Line](topic:Chart.Line) are expressed as a number, or if all x values are expressed as a date string in the `YYYY-MM-DD` format, the chart will be rendered as a time series chart, i.e. x axis values will span across the minimum x value to maximum x value range. + +Otherwise, if x values are represented as a mix of numbers and strings or if at least one x value isn't in the `YYYY-MM-DD` format, the chart will be rendered as a categorical chart, i.e. x axis values will be displayed as categories. """ + + y: Optional[float] = None + """ The y axis value of the data point. """ + + def with_x(self, value: Union[float, str]) -> Self: + self.x = value + return self + + def with_y(self, value: float) -> Self: + self.y = value + return self + + +class LineChartData(SerializableObject): + """Represents a collection of data points series in a line chart.""" + + legend: Optional[str] = None + """ The legend of the chart. """ + + values: Optional[List[LineChartValue]] = None + """ The data points in the series. """ + + color: Optional[ChartColor] = None + """ The color all data points in the series. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_legend(self, value: str) -> Self: + self.legend = value + return self + + def with_values(self, value: List[LineChartValue]) -> Self: + self.values = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class LineChart(CardElement): + """A line chart.""" + + type: Literal["Chart.Line"] = "Chart.Line" + """ Must be **Chart.Line**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + x_axis_title: Optional[str] = None + """ The title of the x axis. """ + + y_axis_title: Optional[str] = None + """ The title of the y axis. """ + + color: Optional[ChartColor] = None + """ The color to use for all data points. See [Chart colors reference](topic:chart-colors-reference). """ + + data: Optional[List[LineChartData]] = None + """ The data point series in the line chart. """ + + y_min: Optional[float] = None + """ The maximum y range. """ + + y_max: Optional[float] = None + """ The minimum y range. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_x_axis_title(self, value: str) -> Self: + self.x_axis_title = value + return self + + def with_y_axis_title(self, value: str) -> Self: + self.y_axis_title = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + def with_data(self, value: List[LineChartData]) -> Self: + self.data = value + return self + + def with_y_min(self, value: float) -> Self: + self.y_min = value + return self + + def with_y_max(self, value: float) -> Self: + self.y_max = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class GaugeChartLegend(SerializableObject): + """The legend of the chart.""" + + size: Optional[float] = None + """ The size of the segment. """ + + legend: Optional[str] = None + """ The legend text associated with the segment. """ + + color: Optional[ChartColor] = None + """ The color to use for the segment. See [Chart colors reference](topic:chart-colors-reference). """ + + def with_size(self, value: float) -> Self: + self.size = value + return self + + def with_legend(self, value: str) -> Self: + self.legend = value + return self + + def with_color(self, value: ChartColor) -> Self: + self.color = value + return self + + +class GaugeChart(CardElement): + """A gauge chart.""" + + type: Literal["Chart.Gauge"] = "Chart.Gauge" + """ Must be **Chart.Gauge**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + title: Optional[str] = None + """ The title of the chart. """ + + color_set: Optional[ChartColorSet] = None + """ The name of the set of colors to use to render the chart. See [Chart colors reference](topic:chart-colors-reference). """ + + min: Optional[float] = None + """ The minimum value of the gauge. """ + + max: Optional[float] = None + """ The maximum value of the gauge. """ + + sub_label: Optional[str] = None + """ The sub-label of the gauge. """ + + show_min_max: Optional[bool] = True + """ Controls if the min/max values should be displayed. """ + + show_legend: Optional[bool] = True + """ Controls if the legend should be displayed. """ + + segments: Optional[List[GaugeChartLegend]] = None + """ The segments to display in the gauge. """ + + value: Optional[float] = None + """ The value of the gauge. """ + + value_format: Optional[GaugeChartValueFormat] = None + """ The format used to display the gauge's value. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_color_set(self, value: ChartColorSet) -> Self: + self.color_set = value + return self + + def with_min(self, value: float) -> Self: + self.min = value + return self + + def with_max(self, value: float) -> Self: + self.max = value + return self + + def with_sub_label(self, value: str) -> Self: + self.sub_label = value + return self + + def with_show_min_max(self, value: bool) -> Self: + self.show_min_max = value + return self + + def with_show_legend(self, value: bool) -> Self: + self.show_legend = value + return self + + def with_segments(self, value: List[GaugeChartLegend]) -> Self: + self.segments = value + return self + + def with_value(self, value: float) -> Self: + self.value = value + return self + + def with_value_format(self, value: GaugeChartValueFormat) -> Self: + self.value_format = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class CodeBlock(CardElement): + """A formatted and syntax-colored code block.""" + + type: Literal["CodeBlock"] = "CodeBlock" + """ Must be **CodeBlock**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + code_snippet: Optional[str] = None + """ The code snippet to display. """ + + language: Optional[CodeLanguage] = None + """ The language the code snippet is expressed in. """ + + start_line_number: Optional[float] = 1 + """ A number that represents the line in the file from where the code snippet was extracted. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_code_snippet(self, value: str) -> Self: + self.code_snippet = value + return self + + def with_language(self, value: CodeLanguage) -> Self: + self.language = value + return self + + def with_start_line_number(self, value: float) -> Self: + self.start_line_number = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class PersonaProperties(SerializableObject): + """Represents the properties of a Persona component.""" + + user_principal_name: Optional[str] = None + """ The UPN of the persona. """ + + display_name: Optional[str] = None + """ The display name of the persona. """ + + def with_user_principal_name(self, value: str) -> Self: + self.user_principal_name = value + return self + + def with_display_name(self, value: str) -> Self: + self.display_name = value + return self + + +class ComUserMicrosoftGraphComponent(CardElement): + """Displays a user's information, including their profile picture.""" + + type: Literal["Component"] = "Component" + """ Must be **Component**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Literal["graph.microsoft.com/user"] = "graph.microsoft.com/user" + """ Must be **graph.microsoft.com/user**. """ + + properties: Optional[PersonaProperties] = None + """ The properties of the user. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_properties(self, value: PersonaProperties) -> Self: + self.properties = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class PersonaSetProperties(SerializableObject): + """Represents the properties of a PersonaSet component.""" + + users: Optional[List[PersonaProperties]] = None + """ The users a PersonaSet component should display. """ + + def with_users(self, value: List[PersonaProperties]) -> Self: + self.users = value + return self + + +class ComUsersMicrosoftGraphComponent(CardElement): + """Displays multiple users' information, including their profile pictures.""" + + type: Literal["Component"] = "Component" + """ Must be **Component**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Literal["graph.microsoft.com/users"] = "graph.microsoft.com/users" + """ Must be **graph.microsoft.com/users**. """ + + properties: Optional[PersonaSetProperties] = None + """ The properties of the set. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_properties(self, value: PersonaSetProperties) -> Self: + self.properties = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class ResourceVisualization(SerializableObject): + """Represents a visualization of a resource.""" + + media: Optional[str] = None + """ The media associated with the resource. """ + + def with_media(self, value: str) -> Self: + self.media = value + return self + + +class ResourceProperties(SerializableObject): + """Represents the properties of a resource component.""" + + id: Optional[str] = None + """ The Id of the resource. """ + + resource_reference: Optional[Dict[str, str]] = None + """ The reference to the resource. """ + + resource_visualization: Optional[ResourceVisualization] = None + """ The visualization of the resource. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_resource_reference(self, value: Dict[str, str]) -> Self: + self.resource_reference = value + return self + + def with_resource_visualization(self, value: ResourceVisualization) -> Self: + self.resource_visualization = value + return self + + +class ComResourceMicrosoftGraphComponent(CardElement): + """Displays information about a generic graph resource.""" + + type: Literal["Component"] = "Component" + """ Must be **Component**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Literal["graph.microsoft.com/resource"] = "graph.microsoft.com/resource" + """ Must be **graph.microsoft.com/resource**. """ + + properties: Optional[ResourceProperties] = None + """ The properties of the resource. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_properties(self, value: ResourceProperties) -> Self: + self.properties = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class FileProperties(SerializableObject): + """Represents the properties of a file component.""" + + name: Optional[str] = None + """ The name of the file. """ + + extension: Optional[str] = None + """ The file extension. """ + + url: Optional[str] = None + """ The URL of the file. """ + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_extension(self, value: str) -> Self: + self.extension = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + +class ComFileMicrosoftGraphComponent(CardElement): + """Displays information about a file resource.""" + + type: Literal["Component"] = "Component" + """ Must be **Component**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Literal["graph.microsoft.com/file"] = "graph.microsoft.com/file" + """ Must be **graph.microsoft.com/file**. """ + + properties: Optional[FileProperties] = None + """ The properties of the file. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_properties(self, value: FileProperties) -> Self: + self.properties = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class CalendarEventAttendee(SerializableObject): + """Represents a calendar event attendee.""" + + name: Optional[str] = None + """ The name of the attendee. """ + + email: Optional[str] = None + """ The email address of the attendee. """ + + title: Optional[str] = None + """ The title of the attendee. """ + + type: Optional[str] = None + """ The type of the attendee. """ + + status: Optional[str] = None + """ The status of the attendee. """ + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_email(self, value: str) -> Self: + self.email = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_type(self, value: str) -> Self: + self.type = value + return self + + def with_status(self, value: str) -> Self: + self.status = value + return self + + +class CalendarEventProperties(SerializableObject): + """The properties of a calendar event.""" + + id: Optional[str] = None + """ The ID of the event. """ + + title: Optional[str] = None + """ The title of the event. """ + + start: Optional[str] = None + """ The start date and time of the event. """ + + end: Optional[str] = None + """ The end date and time of the event. """ + + status: Optional[str] = None + """ The status of the event. """ + + locations: Optional[List[str]] = None + """ The locations of the event. """ + + online_meeting_url: Optional[str] = None + """ The URL of the online meeting. """ + + is_all_day: Optional[bool] = None + """ Indicates if the event is all day. """ + + extension: Optional[str] = None + """ The extension of the event. """ + + url: Optional[str] = None + """ The URL of the event. """ + + attendees: Optional[List[CalendarEventAttendee]] = None + """ The attendees of the event. """ + + organizer: Optional[CalendarEventAttendee] = None + """ The organizer of the event. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_title(self, value: str) -> Self: + self.title = value + return self + + def with_start(self, value: str) -> Self: + self.start = value + return self + + def with_end(self, value: str) -> Self: + self.end = value + return self + + def with_status(self, value: str) -> Self: + self.status = value + return self + + def with_locations(self, value: List[str]) -> Self: + self.locations = value + return self + + def with_online_meeting_url(self, value: str) -> Self: + self.online_meeting_url = value + return self + + def with_is_all_day(self, value: bool) -> Self: + self.is_all_day = value + return self + + def with_extension(self, value: str) -> Self: + self.extension = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_attendees(self, value: List[CalendarEventAttendee]) -> Self: + self.attendees = value + return self + + def with_organizer(self, value: CalendarEventAttendee) -> Self: + self.organizer = value + return self + + +class ComEventMicrosoftGraphComponent(CardElement): + """Displays information about a calendar event.""" + + type: Literal["Component"] = "Component" + """ Must be **Component**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + requires: Optional[HostCapabilities] = Field(default_factory=HostCapabilities) + """ A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided). """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + separator: Optional[bool] = None + """ Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true. """ + + height: Optional[ElementHeight] = None + """ The height of the element. When set to stretch, the element will use the remaining vertical space in its container. """ + + horizontal_alignment: Optional[HorizontalAlignment] = None + """ Controls how the element should be horizontally aligned. """ + + spacing: Optional[Spacing] = None + """ Controls the amount of space between this element and the previous one. No space will be added for the first element in a container. """ + + target_width: Optional[TargetWidth] = None + """ Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see [Responsive layout](topic:responsive-layout). """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Literal["graph.microsoft.com/event"] = "graph.microsoft.com/event" + """ Must be **graph.microsoft.com/event**. """ + + properties: Optional[CalendarEventProperties] = None + """ The properties of the event. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_requires(self, value: HostCapabilities) -> Self: + self.requires = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_separator(self, value: bool) -> Self: + self.separator = value + return self + + def with_height(self, value: ElementHeight) -> Self: + self.height = value + return self + + def with_horizontal_alignment(self, value: HorizontalAlignment) -> Self: + self.horizontal_alignment = value + return self + + def with_spacing(self, value: Spacing) -> Self: + self.spacing = value + return self + + def with_target_width(self, value: TargetWidth) -> Self: + self.target_width = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_properties(self, value: CalendarEventProperties) -> Self: + self.properties = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class TextRun(CardElement): + """A block of text inside a RichTextBlock element.""" + + type: Literal["TextRun"] = "TextRun" + """ Must be **TextRun**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + text: Optional[str] = None + """ The text to display. A subset of markdown is supported. """ + + size: Optional[TextSize] = None + """ The size of the text. """ + + weight: Optional[TextWeight] = None + """ The weight of the text. """ + + color: Optional[TextColor] = None + """ The color of the text. """ + + is_subtle: Optional[bool] = None + """ Controls whether the text should be renderer using a subtler variant of the select color. """ + + font_type: Optional[FontType] = None + """ The type of font to use for rendering. """ + + italic: Optional[bool] = None + """ Controls if the text should be italicized. """ + + strikethrough: Optional[bool] = None + """ Controls if the text should be struck through. """ + + highlight: Optional[bool] = None + """ Controls if the text should be highlighted. """ + + underline: Optional[bool] = None + """ Controls if the text should be underlined. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the text is tapped or clicked. Action.ShowCard is not supported. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_text(self, value: str) -> Self: + self.text = value + return self + + def with_size(self, value: TextSize) -> Self: + self.size = value + return self + + def with_weight(self, value: TextWeight) -> Self: + self.weight = value + return self + + def with_color(self, value: TextColor) -> Self: + self.color = value + return self + + def with_is_subtle(self, value: bool) -> Self: + self.is_subtle = value + return self + + def with_font_type(self, value: FontType) -> Self: + self.font_type = value + return self + + def with_italic(self, value: bool) -> Self: + self.italic = value + return self + + def with_strikethrough(self, value: bool) -> Self: + self.strikethrough = value + return self + + def with_highlight(self, value: bool) -> Self: + self.highlight = value + return self + + def with_underline(self, value: bool) -> Self: + self.underline = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class IconRun(CardElement): + """An inline icon inside a RichTextBlock element.""" + + type: Literal["IconRun"] = "IconRun" + """ Must be **IconRun**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + name: Optional[str] = None + """ The name of the inline icon to display. """ + + size: Optional[SizeEnum] = None + """ The size of the inline icon. """ + + style: Optional[IconStyle] = None + """ The style of the inline icon. """ + + color: Optional[TextColor] = None + """ The color of the inline icon. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the inline icon is tapped or clicked. Action.ShowCard is not supported. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_name(self, value: str) -> Self: + self.name = value + return self + + def with_size(self, value: SizeEnum) -> Self: + self.size = value + return self + + def with_style(self, value: IconStyle) -> Self: + self.style = value + return self + + def with_color(self, value: TextColor) -> Self: + self.color = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self + + +class ThemedUrl(SerializableObject): + """Defines a theme-specific URL.""" + + theme: Optional[ThemeName] = None + """ The theme this URL applies to. """ + + url: Optional[str] = None + """ The URL to use for the associated theme. """ + + def with_theme(self, value: ThemeName) -> Self: + self.theme = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + +class ImageRun(CardElement): + """An inline image inside a RichTextBlock element.""" + + type: Literal["ImageRun"] = "ImageRun" + """ Must be **ImageRun**. """ + + id: Optional[str] = None + """ A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot. """ + + lang: Optional[str] = None + """ The locale associated with the element. """ + + is_visible: Optional[bool] = True + """ Controls the visibility of the element. """ + + is_sort_key: Optional[bool] = None + """ Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements. """ + + url: Optional[str] = None + """ The URL (or Base64-encoded Data URI) of the image. Acceptable formats are PNG, JPEG, GIF and SVG. """ + + size: Optional[SizeEnum] = None + """ The size of the inline image. """ + + style: Optional[ImageStyle] = None + """ The style of the inline image. """ + + select_action: Optional[Action] = None + """ An Action that will be invoked when the image is tapped or clicked. Action.ShowCard is not supported. """ + + themed_urls: Optional[List[ThemedUrl]] = None + """ A set of theme-specific image URLs. """ + + grid_area: Optional[str] = None + """ The area of a Layout.AreaGrid layout in which an element should be displayed. """ + + fallback: Optional[Union[CardElement, FallbackElement]] = None + """ An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property. """ + + def with_id(self, value: str) -> Self: + self.id = value + return self + + def with_lang(self, value: str) -> Self: + self.lang = value + return self + + def with_is_visible(self, value: bool) -> Self: + self.is_visible = value + return self + + def with_is_sort_key(self, value: bool) -> Self: + self.is_sort_key = value + return self + + def with_url(self, value: str) -> Self: + self.url = value + return self + + def with_size(self, value: SizeEnum) -> Self: + self.size = value + return self + + def with_style(self, value: ImageStyle) -> Self: + self.style = value + return self + + def with_select_action(self, value: Action) -> Self: + self.select_action = value + return self + + def with_themed_urls(self, value: List[ThemedUrl]) -> Self: + self.themed_urls = value + return self + + def with_grid_area(self, value: str) -> Self: + self.grid_area = value + return self + + def with_fallback(self, value: Union[CardElement, FallbackElement]) -> Self: + self.fallback = value + return self diff --git a/packages/graph/pyproject.toml b/packages/graph/pyproject.toml index 264af3a2..a84186a3 100644 --- a/packages/graph/pyproject.toml +++ b/packages/graph/pyproject.toml @@ -1,7 +1,3 @@ -[build-system] -requires = ["setuptools>=64", "setuptools-scm>=8"] -build-backend = "setuptools.build_meta" - [project] name = "microsoft-teams-graph" version = "0.0.1-alpha.1" @@ -18,14 +14,6 @@ dependencies = [ "pyjwt[crypto]>=2.10.0", ] -[project.urls] -Homepage = "https://github.com/microsoft/teams.py" -Repository = "https://github.com/microsoft/teams.py" -Issues = "https://github.com/microsoft/teams.py/issues" - -[tool.setuptools.packages.find] -where = ["src"] - [dependency-groups] dev = [ "pytest>=8.4.0", @@ -36,3 +24,13 @@ dev = [ asyncio_mode = "auto" testpaths = ["tests"] python_paths = ["src"] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/microsoft"] + +[tool.uv.sources] +microsoft-teams-common = { workspace = true } \ No newline at end of file diff --git a/packages/graph/src/microsoft/teams/graph/auth_provider.py b/packages/graph/src/microsoft/teams/graph/auth_provider.py index b46f0f48..e515145c 100644 --- a/packages/graph/src/microsoft/teams/graph/auth_provider.py +++ b/packages/graph/src/microsoft/teams/graph/auth_provider.py @@ -85,8 +85,3 @@ def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken: if isinstance(e, ClientAuthenticationError): raise raise ClientAuthenticationError(f"Failed to resolve token: {str(e)}") from e - - -__all__ = [ - "AuthProvider", -] diff --git a/pyproject.toml b/pyproject.toml index 0942b527..f65bfdfd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dev = [ "poethepoet>=0.35.0", "pre-commit>=4.2.0", "ruff>=0.11.13", - "pyright>=1.1.403", + "pyright>=1.1.404", "cookiecutter>=2.6.0", ] @@ -53,6 +53,10 @@ select = ["E", "F", "W", "B", "Q", "I", "ASYNC"] [tool.ruff.lint.flake8-tidy-imports.banned-api] "unittest".msg = "Use `pytest` instead." +[tool.ruff.lint.per-file-ignores] +"packages/cards/**/*.py" = ["E501"] +"packages/cards/**/__init__.py" = ["F403"] + [tool.poe.tasks] fmt = "ruff format" lint = "ruff check" diff --git a/pyrightconfig.json b/pyrightconfig.json index 01c52767..0d443595 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,6 +1,7 @@ { - "include": [ - "packages/**/src/**/*.py" + "include":[ + "packages/**/src/**/*.py", + "tests/**/src/**/*.py" ], "venv": ".venv", "venvPath": ".", @@ -9,6 +10,7 @@ "packages/common/src", "packages/cards/src", "packages/app/src", + "packages/graph/src", "packages/devtools/src" ], "typeCheckingMode": "strict", diff --git a/tests/dialogs/src/main.py b/tests/dialogs/src/main.py index 3366ab67..cbf405d6 100644 --- a/tests/dialogs/src/main.py +++ b/tests/dialogs/src/main.py @@ -44,8 +44,8 @@ async def handle_message(ctx: ActivityContext[MessageActivity]) -> None: """Handle message activities and show dialog launcher card.""" # Create the launcher adaptive card using JSON structure - card = AdaptiveCard( - **{ + card = AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -93,8 +93,8 @@ async def handle_dialog_open(ctx: ActivityContext[TaskFetchInvokeActivity]): dialog_type = data.get("opendialogtype") if data else None if dialog_type == "simple_form": - dialog_card = AdaptiveCard( - **{ + dialog_card = AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -139,8 +139,8 @@ async def handle_dialog_open(ctx: ActivityContext[TaskFetchInvokeActivity]): ) elif dialog_type == "multi_step_form": - dialog_card = AdaptiveCard( - **{ + dialog_card = AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -199,8 +199,8 @@ async def handle_dialog_submit(ctx: ActivityContext[TaskSubmitInvokeActivity]): elif dialog_type == "webpage_dialog_step_1": name = data.get("name") if data else None - next_step_card = AdaptiveCard( - **{ + next_step_card = AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ diff --git a/tests/graph/src/main.py b/tests/graph/src/main.py index 05d32cf3..d201d545 100644 --- a/tests/graph/src/main.py +++ b/tests/graph/src/main.py @@ -9,8 +9,7 @@ from azure.core.exceptions import ClientAuthenticationError from microsoft.teams.api import MessageActivity -from microsoft.teams.app import ActivityContext, App, AppOptions, SignInEvent -from microsoft.teams.app.events.types import ErrorEvent +from microsoft.teams.app import ActivityContext, App, AppOptions, ErrorEvent, SignInEvent from microsoft.teams.graph import get_graph_client from msgraph.generated.users.item.messages.messages_request_builder import ( # type: ignore MessagesRequestBuilder, diff --git a/tests/message-extensions/src/cards.py b/tests/message-extensions/src/cards.py index 49946130..a651db2a 100644 --- a/tests/message-extensions/src/cards.py +++ b/tests/message-extensions/src/cards.py @@ -13,8 +13,8 @@ def create_card(data: Dict[str, str]) -> AdaptiveCard: """Create an adaptive card from form data.""" - return AdaptiveCard( - **{ + return AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -89,15 +89,15 @@ def create_message_details_card(message_payload: Message) -> AdaptiveCard: else: actions = [] - return AdaptiveCard(**{"type": "AdaptiveCard", "version": "1.4", "body": body, "actions": actions}) + return AdaptiveCard.model_validate({"type": "AdaptiveCard", "version": "1.4", "body": body, "actions": actions}) def create_conversation_members_card(members: List[Account]) -> AdaptiveCard: """Create a card showing conversation members.""" members_list = ", ".join(member.name for member in members if member.name) - return AdaptiveCard( - **{ + return AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -131,8 +131,8 @@ async def create_dummy_cards(search_query: str) -> List[Dict[str, Any]]: cards: List[Dict[str, Any]] = [] for item in dummy_items: card_data: Dict[str, Any] = { - "card": AdaptiveCard( - **{ + "card": AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ @@ -166,8 +166,8 @@ def create_link_unfurl_card(url: str) -> Dict[str, Any]: "images": [{"url": IMAGE_URL}], } - card = AdaptiveCard( - **{ + card = AdaptiveCard.model_validate( + { "type": "AdaptiveCard", "version": "1.4", "body": [ diff --git a/uv.lock b/uv.lock index 0a1a341a..e7a2620f 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 1 +revision = 3 requires-python = ">=3.12" [manifest] @@ -936,7 +936,7 @@ dev = [ { name = "cookiecutter", specifier = ">=2.6.0" }, { name = "poethepoet", specifier = ">=0.35.0" }, { name = "pre-commit", specifier = ">=4.2.0" }, - { name = "pyright", specifier = ">=1.1.403" }, + { name = "pyright", specifier = ">=1.1.404" }, { name = "ruff", specifier = ">=0.11.13" }, ] @@ -1512,15 +1512,15 @@ crypto = [ [[package]] name = "pyright" -version = "1.1.403" +version = "1.1.404" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/fe/f6/35f885264ff08c960b23d1542038d8da86971c5d8c955cfab195a4f672d7/pyright-1.1.403.tar.gz", hash = "sha256:3ab69b9f41c67fb5bbb4d7a36243256f0d549ed3608678d381d5f51863921104", size = 3913526 } +sdist = { url = "https://files.pythonhosted.org/packages/e2/6e/026be64c43af681d5632722acd100b06d3d39f383ec382ff50a71a6d5bce/pyright-1.1.404.tar.gz", hash = "sha256:455e881a558ca6be9ecca0b30ce08aa78343ecc031d37a198ffa9a7a1abeb63e", size = 4065679, upload-time = "2025-08-20T18:46:14.029Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/49/b6/b04e5c2f41a5ccad74a1a4759da41adb20b4bc9d59a5e08d29ba60084d07/pyright-1.1.403-py3-none-any.whl", hash = "sha256:c0eeca5aa76cbef3fcc271259bbd785753c7ad7bcac99a9162b4c4c7daed23b3", size = 5684504 }, + { url = "https://files.pythonhosted.org/packages/84/30/89aa7f7d7a875bbb9a577d4b1dc5a3e404e3d2ae2657354808e905e358e0/pyright-1.1.404-py3-none-any.whl", hash = "sha256:c7b7ff1fdb7219c643079e4c3e7d4125f0dafcc19d253b47e898d130ea426419", size = 5902951, upload-time = "2025-08-20T18:46:12.096Z" }, ] [[package]]