Teams API Reference¶
Access Microsoft Teams through the notifications namespace:
from fabias.notifications import teams
teams.client(team_id="...", channel_id="...", auth=my_auth)
teams.send("Pipeline completed!")
Module Functions¶
fabias.notifications.teams.client
¶
Microsoft Teams (Graph API) client.
Classes¶
TeamsClient
¶
Bases: BaseClient
HTTP client for Microsoft Teams via Graph API.
Configured for a specific team with a default channel.
Source code in src/fabias/notifications/teams/client.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Attributes¶
channelId
property
¶
Get the default channel ID.
teamId
property
¶
Get the configured team ID.
Functions¶
__init__(team_id, channel_id, auth=None, tenant_id=None, client_id=None, client_secret=None)
¶
Initialize the Teams client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
str
|
Microsoft Teams team ID |
required |
channel_id
|
str
|
Default channel ID |
required |
auth
|
Optional[AuthProvider]
|
Optional pre-configured AuthProvider |
None
|
tenant_id
|
Optional[str]
|
Azure AD tenant ID |
None
|
client_id
|
Optional[str]
|
Application client ID |
None
|
client_secret
|
Optional[str]
|
Client secret |
None
|
Source code in src/fabias/notifications/teams/client.py
channel(channel_id)
¶
Get a Channel object for a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id
|
str
|
Channel ID |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Channel |
Channel
|
Channel for sending messages |
Source code in src/fabias/notifications/teams/client.py
getResource(resource_type, **kwargs)
¶
Generic resource access for dynamic getattr fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_type
|
str
|
Resource type/path |
required |
Returns:
| Type | Description |
|---|---|
Any
|
API response data |
Source code in src/fabias/notifications/teams/client.py
listChannels()
¶
List all channels in the team.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[Dict[str, Any]]
|
List of channel metadata |
Source code in src/fabias/notifications/teams/client.py
send(content, subject=None)
¶
Send a message to the default channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Union[str, Any]
|
Message text or Adaptive Card |
required |
subject
|
Optional[str]
|
Optional message subject |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
API response |
Source code in src/fabias/notifications/teams/client.py
fabias.notifications.teams.send(content, subject=None)
¶
Send a message to the default channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Union[str, Any]
|
Message text or Adaptive Card |
required |
subject
|
Optional[str]
|
Optional message subject |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
API response with message ID |
Examples:
>>> teams.send("Hello world!")
>>> teams.send("Alert", subject="Important")
>>> teams.send(my_adaptive_card)
Source code in src/fabias/notifications/teams/__init__.py
fabias.notifications.teams.channel
¶
Microsoft Teams Channel model.
Classes¶
Channel
¶
Represents a Microsoft Teams channel.
Provides methods to send messages, including Adaptive Cards.
Examples:
>>> import fabias.teams as teams
>>> teams.client(team_id="...", channel_id="...", auth=auth)
>>> teams.send("Hello!") # Default channel
>>> teams.channel("other-id").send("Hello other channel!")
Source code in src/fabias/notifications/teams/channel.py
Functions¶
__init__(client, team_id, channel_id)
¶
Initialize channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
TeamsClient
|
Configured TeamsClient |
required |
team_id
|
str
|
Parent team ID |
required |
channel_id
|
str
|
Channel ID |
required |
Source code in src/fabias/notifications/teams/channel.py
send(content, subject=None)
¶
Send a message to this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Union[str, Any]
|
Message text or Adaptive Card |
required |
subject
|
Optional[str]
|
Optional message subject |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
API response with message ID |
Examples:
>>> channel.send("Hello world!")
>>> channel.send("Alert message", subject="Important")
>>> channel.send(my_adaptive_card)
Source code in src/fabias/notifications/teams/channel.py
Classes¶
fabias.notifications.teams.Channel
¶
Represents a Microsoft Teams channel.
Provides methods to send messages, including Adaptive Cards.
Examples:
>>> import fabias.teams as teams
>>> teams.client(team_id="...", channel_id="...", auth=auth)
>>> teams.send("Hello!") # Default channel
>>> teams.channel("other-id").send("Hello other channel!")
Source code in src/fabias/notifications/teams/channel.py
Attributes¶
teamId = team_id
instance-attribute
¶
Functions¶
send(content, subject=None)
¶
Send a message to this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Union[str, Any]
|
Message text or Adaptive Card |
required |
subject
|
Optional[str]
|
Optional message subject |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
API response with message ID |
Examples:
>>> channel.send("Hello world!")
>>> channel.send("Alert message", subject="Important")
>>> channel.send(my_adaptive_card)
Source code in src/fabias/notifications/teams/channel.py
fabias.notifications.teams.TeamsClient
¶
Bases: BaseClient
HTTP client for Microsoft Teams via Graph API.
Configured for a specific team with a default channel.
Source code in src/fabias/notifications/teams/client.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Attributes¶
teamId
property
¶
Get the configured team ID.
channelId
property
¶
Get the default channel ID.
Functions¶
send(content, subject=None)
¶
Send a message to the default channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Union[str, Any]
|
Message text or Adaptive Card |
required |
subject
|
Optional[str]
|
Optional message subject |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
API response |
Source code in src/fabias/notifications/teams/client.py
channel(channel_id)
¶
Get a Channel object for a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id
|
str
|
Channel ID |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Channel |
Channel
|
Channel for sending messages |
Source code in src/fabias/notifications/teams/client.py
listChannels()
¶
List all channels in the team.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[Dict[str, Any]]
|
List of channel metadata |
Source code in src/fabias/notifications/teams/client.py
getResource(resource_type, **kwargs)
¶
Generic resource access for dynamic getattr fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_type
|
str
|
Resource type/path |
required |
Returns:
| Type | Description |
|---|---|
Any
|
API response data |
Source code in src/fabias/notifications/teams/client.py
Cards Module¶
fabias.notifications.cards.Adaptive
¶
Bases: CardElement
Represents a Microsoft Adaptive Card.
Adaptive Cards are platform-agnostic UI snippets that can be rendered in Microsoft Teams, Outlook, and other Microsoft 365 apps.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "AdaptiveCard" |
version |
str
|
Adaptive Card schema version |
body |
list
|
List of card elements to display |
actions |
list
|
List of interactive actions |
speak |
str
|
Text-to-speech content for accessibility |
Examples:
Simple card:
>>> from fabias.cards import Adaptive, TextBlock
>>> card = Adaptive(body=[
... TextBlock("Hello!", weight="Bolder", size="Large"),
... TextBlock("Welcome to fabias!")
... ])
Card with actions:
>>> from fabias.cards import Adaptive, TextBlock, ActionOpenUrl
>>> card = Adaptive(
... body=[TextBlock("Check out our docs")],
... actions=[ActionOpenUrl("icon:Book", "Docs", "https://docs.example.com")]
... )
Send via Teams:
Source code in src/fabias/notifications/cards/cards.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Functions¶
__init__(body=None, actions=None, speak=None, version='1.5')
¶
Initialize an Adaptive Card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
Optional[List]
|
List of card elements to display |
None
|
actions
|
Optional[List]
|
List of actions available on the card |
None
|
speak
|
Optional[str]
|
Text to be spoken for accessibility |
None
|
version
|
str
|
Adaptive Card schema version (default "1.5") |
'1.5'
|
Source code in src/fabias/notifications/cards/cards.py
addAction(action)
¶
Add an action to the card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
CardElement
|
Action element to add |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Adaptive |
Adaptive
|
Self for method chaining |
Source code in src/fabias/notifications/cards/cards.py
addElement(element)
¶
Add an element to the card body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
CardElement
|
Card element to add |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Adaptive |
Adaptive
|
Self for method chaining |
Source code in src/fabias/notifications/cards/cards.py
content()
¶
Return JSON string representation of the card.
This is used when sending cards via the Graph API, which expects the card content as a JSON string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON-serialized card content |
Source code in src/fabias/notifications/cards/cards.py
to_dict()
¶
Convert card to dictionary, adding the $schema field.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Any]
|
Dictionary representation with schema URL |
Source code in src/fabias/notifications/cards/cards.py
fabias.notifications.cards.TextBlock
¶
Bases: CardElement
Text block element for displaying text in a card.
Supports various text styling options including size, weight, color, and font type.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "TextBlock" |
text |
str
|
Text content to display |
wrap |
bool
|
Whether text should wrap |
weight |
str
|
Font weight (e.g., "Bolder", "Lighter") |
size |
str
|
Font size (e.g., "Small", "Medium", "Large", "ExtraLarge") |
color |
str
|
Text color (e.g., "Default", "Warning", "Attention") |
style |
str
|
Text style (e.g., "default", "heading") |
fontType |
str
|
Font type (e.g., "Monospace") |
Examples:
>>> title = TextBlock("Welcome!", weight="Bolder", size="Large")
>>> subtitle = TextBlock("This is a subtitle", color="Accent")
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__(text, wrap=True, weight=None, size=None, color=None, style='default', fontType=None)
¶
Initialize a TextBlock element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text content to display |
required |
wrap
|
bool
|
Whether text should wrap (default True) |
True
|
weight
|
Optional[str]
|
Font weight ("Bolder", "Lighter") |
None
|
size
|
Optional[str]
|
Font size ("Small", "Medium", "Large", "ExtraLarge") |
None
|
color
|
Optional[str]
|
Text color ("Default", "Warning", "Attention", "Accent") |
None
|
style
|
Optional[str]
|
Text style ("default", "heading") |
'default'
|
fontType
|
Optional[str]
|
Font type ("Default", "Monospace") |
None
|
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.ColumnSet
¶
Bases: CardElement
ColumnSet element for multi-column layouts.
Contains one or more Column elements arranged horizontally.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "ColumnSet" |
columns |
list
|
List of Column elements |
style |
str
|
Optional style for the column set |
Examples:
>>> cols = ColumnSet()
>>> cols.addColumn([TextBlock("Left")], width="1")
>>> cols.addColumn([TextBlock("Right")], width="1")
>>> # Or with columns directly:
>>> cols = ColumnSet(columns=[
... Column([TextBlock("A")], width="auto"),
... Column([TextBlock("B")], width="stretch")
... ])
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__(style=None, columns=None)
¶
Initialize a ColumnSet element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
Optional[str]
|
Optional style for the column set |
None
|
columns
|
Optional[List]
|
Optional list of Column elements |
None
|
Source code in src/fabias/notifications/cards/elements.py
addColumn(content, width='stretch')
¶
Add a column to this ColumnSet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
List
|
List of CardElement objects for the column |
required |
width
|
Optional[str]
|
Column width |
'stretch'
|
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.Column
¶
Bases: CardElement
Column element for use within a ColumnSet.
Columns contain a list of items and have configurable width.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "Column" |
width |
str
|
Column width ("auto", "stretch", or pixel/weight value) |
items |
list
|
List of card elements in this column |
Examples:
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__(content, width='stretch')
¶
Initialize a Column element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
List
|
List of CardElement objects or dicts |
required |
width
|
Optional[str]
|
Column width ("auto", "stretch", or specific value) |
'stretch'
|
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.Image
¶
Bases: CardElement
Image element for displaying images in a card.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "Image" |
url |
str
|
Image URL |
size |
str
|
Image size ("Auto", "Stretch", "Small", "Medium", "Large") |
altText |
str
|
Alternative text for accessibility |
Examples:
>>> logo = Image("https://example.com/logo.png", size="Medium")
>>> avatar = Image(url, alt_text="User avatar")
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__(url, size=None, alt_text=None)
¶
Initialize an Image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Image URL |
required |
size
|
Optional[str]
|
Image size ("Auto", "Stretch", "Small", "Medium", "Large") |
None
|
alt_text
|
Optional[str]
|
Alternative text for accessibility |
None
|
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.Table
¶
Bases: CardElement
Table element for displaying tabular data.
Supports header rows and data rows with configurable column widths.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "Table" |
columns |
list
|
Column definitions with widths |
rows |
list
|
Table rows (header + data) |
Examples:
>>> table = Table()
>>> table.setHeaders([
... {"name": "Name", "width": 2},
... {"name": "Status", "width": 1}
... ])
>>> table.addRow(["Item 1", "Active"])
>>> table.addRow(["Item 2", "Inactive"])
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__()
¶
addRow(row_data)
¶
Add a data row to the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_data
|
List
|
List of cell values (will be converted to strings) |
required |
Examples:
Source code in src/fabias/notifications/cards/elements.py
setHeaders(header_data)
¶
Set the table header row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_data
|
List[Dict]
|
List of header definitions, each containing: - width (int): Column width weight (default 1) - name (str, optional): Header text |
required |
Examples:
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.Badge
¶
Bases: CardElement
Badge element for displaying a badge/tag in a card.
Badges are small labels that can include icons and various styles.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Always "Badge" |
text |
str
|
Badge text |
size |
str
|
Badge size |
style |
str
|
Badge style ("Accent", "Default", etc.) |
icon |
str
|
Icon name |
iconPosition |
str
|
Icon position relative to text |
Examples:
>>> status = Badge("Active", style="Accent", icon="CheckMark")
>>> env = Badge("Production", style="Warning")
Source code in src/fabias/notifications/cards/elements.py
Functions¶
__init__(text, spacing=None, horizontalAlignment=None, size=None, style='Accent', icon=None, position=None)
¶
Initialize a Badge element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Badge text |
required |
spacing
|
Optional[str]
|
Spacing around the badge |
None
|
horizontalAlignment
|
Optional[str]
|
Horizontal alignment |
None
|
size
|
Optional[str]
|
Badge size |
None
|
style
|
Optional[str]
|
Badge style ("Accent", "Default", "Subtle") |
'Accent'
|
icon
|
Optional[str]
|
Icon name |
None
|
position
|
Optional[str]
|
Icon position ("Before", "After") |
None
|
Source code in src/fabias/notifications/cards/elements.py
fabias.notifications.cards.ActionShowCard
¶
Bases: ActionElement
Action that shows a nested card when clicked.
Useful for progressive disclosure of information, allowing users to expand additional details on demand.
Examples:
>>> details_card = Adaptive(body=[
... TextBlock("Additional details here...")
... ])
>>> action = ActionShowCard(
... icon="icon:Info",
... title="Show Details",
... card=details_card
... )
Source code in src/fabias/notifications/cards/actions.py
Functions¶
__init__(icon, title, card)
¶
Initialize a ShowCard action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
icon
|
str
|
Icon URL or icon reference (e.g., "icon:Info") |
required |
title
|
str
|
Action button title |
required |
card
|
Adaptive
|
Adaptive card to show when clicked |
required |
Source code in src/fabias/notifications/cards/actions.py
fabias.notifications.cards.ActionOpenUrl
¶
Bases: ActionElement
Action that opens a URL when clicked.
Opens the specified URL in a new browser tab or the platform's default handler.
Examples:
>>> action = ActionOpenUrl(
... icon="icon:Link",
... title="Learn More",
... url="https://example.com/docs"
... )
Source code in src/fabias/notifications/cards/actions.py
Functions¶
__init__(icon, title, url, icon_url=None)
¶
Initialize an OpenUrl action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
icon
|
str
|
Icon URL or icon reference (e.g., "icon:Link") |
required |
title
|
str
|
Action button title |
required |
url
|
str
|
URL to open when clicked |
required |
icon_url
|
Optional[str]
|
Deprecated - use icon parameter |
None
|