adaptive-cards-py


Nameadaptive-cards-py JSON
Version 0.0.8 PyPI version JSON
download
home_page
SummaryPython wrapper library for building beautiful adaptive cards
upload_time2023-12-23 18:41:20
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2023 Dennis Eder Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords bot ui adaptivecards cards adaptivecardsio python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Adaptive Cards

A thin Python wrapper for creating [**Adaptive Cards**](https://adaptivecards.io/) easily on code level. The deep integration of Python's `typing` package prevents you from creating invalid schemes and guides you while creating visual apealing cards. 

If you are interested in the general concepts of adaptive cards and want to dig a bit deeper, have a look into the [**official documentation**](https://learn.microsoft.com/en-us/adaptive-cards/) or start a jump start and get used to the [**schema**](https://adaptivecards.io/explorer/).

💡 **Please note**
<br>This library is still in progress and is lacking some features. However, missing fractions are planned to be added soon. 

## About

This library is intended to provide a clear and simple interface for creating adaptive cards with only a few lines of code in a more robust way. The heavy usage of Python's typing library should
prevent one from creating invalid schemes and structures. Instead, creating cards should be intuitive and work like a breeze. 

For a comprehensive introduction into the main ideas and patterns of adaptive cards, have a look on the [**official documentation**](https://docs.microsoft.com/en-us/adaptive-cards). I also recommend using the [**schema explorer**](https://adaptivecards.io/explorer) page alongside the implementation, since the library's type system relies on these schemes.

💡 **Please note**
<br>It's highly recommended to turn on the **type check** capabilities for Python in your editor. This will serve you with direct feedback about the structures you create. If you are trying to assign values of incompatible types, your editor will mark it as such and yell at you right in the moment you are about to do so.

## Features

+ Type annotated components based on Python's **dataclasses**
+ Schema validation for version compatibility
+ Simple `JSON` export
+ Compliant with the official structures and ideas

## Dependencies

* Python 3.10+
* `dataclasses-json`
* `StrEnum`

## Installation

```bash
pip install adaptive-cards-py
```

## Library structure

**Adaptive cards** can consist of different kind of components. The four main categories beside the actual cards are **Elements**, **Containers**, **Actions** and **Inputs**. You can find all available components for each category within the corresponding file. The `AdaptiveCard` is defined in `cards.py`.

In addition to that, some fields of certain components are of custom types. These types are living inside the `card_types.py` file. For instance, if you are about to assign a color to a `TextBlock`, the field `color` will only accept a value of type `Colors`, which is implemented in the aforementioned Python file.

To perform validation on a fully initialized card, one can make use of the `SchemaValidator` class. Similar to the whole library, this class provides a simple interface with only on method. The validation currently checks whether all used fields are compliant with the overall card version

## Usage

### A simple card

A simple `TextBlock` lives in the `elements` module and can be used after it's import. 

```Python
from adaptive_cards.elements import TextBlock

text_block: TextBlock = TextBlock(text="It's your first card")
```
For this component, `text` is the only required property. However, if more customization is needed, further available fields can be used.

```Python
from adaptive_cards.elements import TextBlock
import adaptive_cards.card_types as types

text_block: TextBlock = TextBlock(
    text="It's your second card",
    color=types.Colors.ACCENT,
    size=types.FontSize.EXTRA_LARGE,
    horizontal_alignment=types.HorizontalAlignment.CENTER,
)
```

An actual card with only this component can be created like this.

```Python
from adaptive_cards.card import AdaptiveCard

...

version: str = "1.4"
card: AdaptiveCard = AdaptiveCard.new() \
                                 .version(version) \
                                 .add_item(text_block) \
                                 .create()
```

Find your final layout below.

![simple card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card.jpg?raw=true)

💡 **Please note**
<br>After building the object is done, the `create(...)` method must be called in order to create the final object. In this case, the object will be of type `AdaptiveCard`.

To directly export your result, make use of the 
`to_json()` method provided by every card.

```Python
with open("path/to/out/file.json", "w+") as f:
    f.write(card.to_json())

```

### Adding multiple elements at once

Assuming you have a bunch of elements you want your card to enrich with. There is also a method for doing so. Let's re-use the example from before, but add another `Image` element here as well. 

```Python
from adaptive_cards.elements import TextBlock, Image
import adaptive_cards.card_types as types

text_block: TextBlock = TextBlock(
    text="It's your third card"
    color=types.Colors.ACCENT,
    size=types.FontSize.EXTRA_LARGE,
    horizontal_alignment=types.HorizontalAlignment.CENTER,
)

image: Image = Image(url="https://adaptivecards.io/content/bf-logo.png")

version: str = "1.4"
card: AdaptiveCard = AdaptiveCard.new() \
                                 .version(version) \
                                 .add_items([text_block, image]) \
                                 .create()

# Alternatively, you can also chain multiple add_item(...) functions:
# card = AdaptiveCard.new() \
#                    .version(version) \
#                    .add_item(text_block) \
#                    .add_item(image) \
#                    .create()


with open("path/to/out/file.json", "w+") as f:
    f.write(card.to_json())
```

This will result in a card like shown below.

![simple card 2](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card_2.jpg?raw=true)

### Finally, a more complex card

You can have a look on the following example for getting an idea of what's actually possible
with adaptive cards. 

![wrap up card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/wrap_up_card/wrap_up_card.jpg?raw=true)

<details>
<summary>Code</summary>

```python
import adaptive_cards.card_types as types
from adaptive_cards.actions import ActionToggleVisibility, TargetElement
from adaptive_cards.validation import SchemaValidator, Result
from adaptive_cards.card import AdaptiveCard
from adaptive_cards.elements import TextBlock, Image
from adaptive_cards.containers import Container, ContainerTypes, ColumnSet, Column

containers: list[ContainerTypes] = []

icon_source: str = "https://icons8.com/icon/vNXFqyQtOSbb/launch"
icon_url: str = "https://img.icons8.com/3d-fluency/94/launched-rocket.png"

header_column_set: ColumnSet = ColumnSet(
    columns=[
        Column(
            items=[
                TextBlock(text="Your Daily Wrap-Up", size=types.FontSize.EXTRA_LARGE)
            ],
            width="stretch",
        ),
        Column(items=[Image(url=icon_url, width="40px")], rtl=True, width="auto"),
    ]
)
containers.append(
    Container(
        items=[header_column_set], style=types.ContainerStyle.EMPHASIS, bleed=True
    )
)

containers.append(
    Container(
        items=[
            TextBlock(
                text="**Some numbers for you**",
                size=types.FontSize.MEDIUM,
            ),
            ColumnSet(
                columns=[
                    Column(
                        items=[
                            TextBlock(text="_Total_"),
                            TextBlock(text="_Done by you_"),
                            TextBlock(text="_Done by other teams_"),
                            TextBlock(text="_Still open_"),
                            TextBlock(text="_Closed_"),
                        ]
                    ),
                    Column(
                        items=[
                            TextBlock(text="5"),
                            TextBlock(text="4"),
                            TextBlock(text="3"),
                            TextBlock(text="6"),
                            TextBlock(text="1"),
                        ],
                        spacing=types.Spacing.MEDIUM,
                        rtl=True,
                    ),
                ],
                separator=True,
            ),
        ],
        spacing=types.Spacing.MEDIUM,
    )
)

containers.append(
    Container(
        items=[
            TextBlock(
                text="**Detailed Results**",
                size=types.FontSize.MEDIUM,
            ),
        ],
        separator=True,
        spacing=types.Spacing.EXTRA_LARGE,
    )
)

sample_column_set: ColumnSet = ColumnSet(
    columns=[
        Column(items=[TextBlock(text="12312")]),
        Column(items=[TextBlock(text="done", color=types.Colors.GOOD)]),
        Column(items=[TextBlock(text="abc")]),
        Column(
            items=[
                Image(
                    url="https://adaptivecards.io/content/down.png",
                    width="20px",
                    horizontal_alignment=types.HorizontalAlignment.RIGHT,
                )
            ],
            select_action=ActionToggleVisibility(
                title="More",
                target_elements=[
                    TargetElement(
                        element_id="toggle-me",
                    )
                ],
            ),
        ),
    ]
)

containers.append(
    Container(
        items=[
            Container(
                items=[
                    ColumnSet(
                        columns=[
                            Column(items=[TextBlock(text="**Number**")]),
                            Column(items=[TextBlock(text="**Status**")]),
                            Column(items=[TextBlock(text="**Topic**")]),
                            Column(items=[TextBlock(text="")]),
                        ],
                        id="headline",
                    ),
                ],
                style=types.ContainerStyle.EMPHASIS,
                bleed=True,
            ),
            Container(items=[sample_column_set]),
            Container(
                items=[
                    TextBlock(
                        text="_Here you gonna find more information about the whole topic_",
                        id="toggle-me",
                        is_visible=False,
                        is_subtle=True,
                        wrap=True,
                    )
                ]
            ),
        ],
    )
)

containers.append(
    Container(
        items=[
            TextBlock(
                text=f"Icon used from: {icon_source}",
                size=types.FontSize.SMALL,
                horizontal_alignment=types.HorizontalAlignment.CENTER,
                is_subtle=True,
            )
        ]
    )
)

card = AdaptiveCard.new().version("1.5").add_items(containers).create()

validator: SchemaValidator = SchemaValidator()
result: Result = validator.validate(card)

print(f"Validation was successful: {result == Result.SUCCESS}")

```

</details>

<details>
<summary>Schema</summary>

```json
{
    "type": "AdaptiveCard",
    "version": "1.5",
    "schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "body": [
        {
            "items": [
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "items": [
                                {
                                    "text": "Your Daily Wrap-Up",
                                    "type": "TextBlock",
                                    "size": "extraLarge"
                                }
                            ],
                            "width": "stretch"
                        },
                        {
                            "items": [
                                {
                                    "url": "https://img.icons8.com/3d-fluency/94/launched-rocket.png",
                                    "type": "Image",
                                    "width": "40px"
                                }
                            ],
                            "rtl": true,
                            "width": "auto"
                        }
                    ]
                }
            ],
            "type": "Container",
            "style": "emphasis",
            "bleed": true
        },
        {
            "spacing": "medium",
            "items": [
                {
                    "text": "**Some numbers for you**",
                    "type": "TextBlock",
                    "size": "medium"
                },
                {
                    "separator": true,
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "items": [
                                {
                                    "text": "_Total_",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "_Done by you_",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "_Done by other teams_",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "_Still open_",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "_Closed_",
                                    "type": "TextBlock"
                                }
                            ]
                        },
                        {
                            "spacing": "medium",
                            "items": [
                                {
                                    "text": "5",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "4",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "3",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "6",
                                    "type": "TextBlock"
                                },
                                {
                                    "text": "1",
                                    "type": "TextBlock"
                                }
                            ],
                            "rtl": true
                        }
                    ]
                }
            ],
            "type": "Container"
        },
        {
            "separator": true,
            "spacing": "extraLarge",
            "items": [
                {
                    "text": "**Detailed Results**",
                    "type": "TextBlock",
                    "size": "medium"
                }
            ],
            "type": "Container"
        },
        {
            "items": [
                {
                    "items": [
                        {
                            "id": "headline",
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "items": [
                                        {
                                            "text": "**Number**",
                                            "type": "TextBlock"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "text": "**Status**",
                                            "type": "TextBlock"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "text": "**Topic**",
                                            "type": "TextBlock"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "text": "",
                                            "type": "TextBlock"
                                        }
                                    ]
                                }
                            ]
                        }
                    ],
                    "type": "Container",
                    "style": "emphasis",
                    "bleed": true
                },
                {
                    "items": [
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "items": [
                                        {
                                            "text": "12312",
                                            "type": "TextBlock"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "text": "done",
                                            "type": "TextBlock",
                                            "color": "good"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "text": "abc",
                                            "type": "TextBlock"
                                        }
                                    ]
                                },
                                {
                                    "items": [
                                        {
                                            "url": "https://adaptivecards.io/content/down.png",
                                            "type": "Image",
                                            "horizontalAlignment": "right",
                                            "width": "20px"
                                        }
                                    ],
                                    "selectAction": {
                                        "title": "More",
                                        "targetElements": [
                                            {
                                                "elementId": "toggle-me"
                                            }
                                        ],
                                        "type": "Action.ToggleVisibility"
                                    }
                                }
                            ]
                        }
                    ],
                    "type": "Container"
                },
                {
                    "items": [
                        {
                            "id": "toggle-me",
                            "isVisible": false,
                            "text": "_Here you gonna find more information about the whole topic_",
                            "type": "TextBlock",
                            "isSubtle": true,
                            "wrap": true
                        }
                    ],
                    "type": "Container"
                }
            ],
            "type": "Container"
        },
        {
            "items": [
                {
                    "text": "Icon used from: https://icons8.com/icon/vNXFqyQtOSbb/launch",
                    "type": "TextBlock",
                    "horizontalAlignment": "center",
                    "isSubtle": true,
                    "size": "small"
                }
            ],
            "type": "Container"
        }
    ]
}
```


</details>

But we are still scratching the surface. You can do even better!



### Validate schema

New components and fields are getting introduced every now and then. This means, if you are using an early version for a card and add fields, which are not compliant with it, you will have an invalid schema. To prevent you from exporting fields not yet supported by the card and target framework, a schema validation can be performed. It's as simple as that:

```Python
from adaptive_cards.validator import SchemaValidator, Result

...

version: str = "1.4"
card: AdaptiveCard = AdaptiveCard.new() \
                                 .version(version) \
                                 .add_items([text_block, image]) \
                                 .create()

validator: SchemaValidator = SchemaValidator()
result: Result = validator.validate(card)

print(f"Validation was successful: {result == Result.SUCCESS}")

```

## Examples

If you are interested in more comprehensive examples or the actual source code, have a look into the `examples` folder. 

## Contribution

Feel free to create issues, fork the repository or even come up with a pull request. I am happy about any kind of contribution and would love
to hear your feedback! 

## Roadmap

- [x] 📕 Comprehensive documentation on code level
- [x] 🐍 Ready to use Python package
- [ ] 🚀 More and better examples
- [ ] 🔎 Comprehensive validation

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "adaptive-cards-py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "bot,ui,adaptivecards,cards,adaptivecardsio,python",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/69/26/a014c1d67be6ad718f4f08b74753ec9909324774fe22220470fde4545ace/adaptive-cards-py-0.0.8.tar.gz",
    "platform": null,
    "description": "# Adaptive Cards\n\nA thin Python wrapper for creating [**Adaptive Cards**](https://adaptivecards.io/) easily on code level. The deep integration of Python's `typing` package prevents you from creating invalid schemes and guides you while creating visual apealing cards. \n\nIf you are interested in the general concepts of adaptive cards and want to dig a bit deeper, have a look into the [**official documentation**](https://learn.microsoft.com/en-us/adaptive-cards/) or start a jump start and get used to the [**schema**](https://adaptivecards.io/explorer/).\n\n\ud83d\udca1 **Please note**\n<br>This library is still in progress and is lacking some features. However, missing fractions are planned to be added soon. \n\n## About\n\nThis library is intended to provide a clear and simple interface for creating adaptive cards with only a few lines of code in a more robust way. The heavy usage of Python's typing library should\nprevent one from creating invalid schemes and structures. Instead, creating cards should be intuitive and work like a breeze. \n\nFor a comprehensive introduction into the main ideas and patterns of adaptive cards, have a look on the [**official documentation**](https://docs.microsoft.com/en-us/adaptive-cards). I also recommend using the [**schema explorer**](https://adaptivecards.io/explorer) page alongside the implementation, since the library's type system relies on these schemes.\n\n\ud83d\udca1 **Please note**\n<br>It's highly recommended to turn on the **type check** capabilities for Python in your editor. This will serve you with direct feedback about the structures you create. If you are trying to assign values of incompatible types, your editor will mark it as such and yell at you right in the moment you are about to do so.\n\n## Features\n\n+ Type annotated components based on Python's **dataclasses**\n+ Schema validation for version compatibility\n+ Simple `JSON` export\n+ Compliant with the official structures and ideas\n\n## Dependencies\n\n* Python 3.10+\n* `dataclasses-json`\n* `StrEnum`\n\n## Installation\n\n```bash\npip install adaptive-cards-py\n```\n\n## Library structure\n\n**Adaptive cards** can consist of different kind of components. The four main categories beside the actual cards are **Elements**, **Containers**, **Actions** and **Inputs**. You can find all available components for each category within the corresponding file. The `AdaptiveCard` is defined in `cards.py`.\n\nIn addition to that, some fields of certain components are of custom types. These types are living inside the `card_types.py` file. For instance, if you are about to assign a color to a `TextBlock`, the field `color` will only accept a value of type `Colors`, which is implemented in the aforementioned Python file.\n\nTo perform validation on a fully initialized card, one can make use of the `SchemaValidator` class. Similar to the whole library, this class provides a simple interface with only on method. The validation currently checks whether all used fields are compliant with the overall card version\n\n## Usage\n\n### A simple card\n\nA simple `TextBlock` lives in the `elements` module and can be used after it's import. \n\n```Python\nfrom adaptive_cards.elements import TextBlock\n\ntext_block: TextBlock = TextBlock(text=\"It's your first card\")\n```\nFor this component, `text` is the only required property. However, if more customization is needed, further available fields can be used.\n\n```Python\nfrom adaptive_cards.elements import TextBlock\nimport adaptive_cards.card_types as types\n\ntext_block: TextBlock = TextBlock(\n    text=\"It's your second card\",\n    color=types.Colors.ACCENT,\n    size=types.FontSize.EXTRA_LARGE,\n    horizontal_alignment=types.HorizontalAlignment.CENTER,\n)\n```\n\nAn actual card with only this component can be created like this.\n\n```Python\nfrom adaptive_cards.card import AdaptiveCard\n\n...\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_item(text_block) \\\n                                 .create()\n```\n\nFind your final layout below.\n\n![simple card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card.jpg?raw=true)\n\n\ud83d\udca1 **Please note**\n<br>After building the object is done, the `create(...)` method must be called in order to create the final object. In this case, the object will be of type `AdaptiveCard`.\n\nTo directly export your result, make use of the \n`to_json()` method provided by every card.\n\n```Python\nwith open(\"path/to/out/file.json\", \"w+\") as f:\n    f.write(card.to_json())\n\n```\n\n### Adding multiple elements at once\n\nAssuming you have a bunch of elements you want your card to enrich with. There is also a method for doing so. Let's re-use the example from before, but add another `Image` element here as well. \n\n```Python\nfrom adaptive_cards.elements import TextBlock, Image\nimport adaptive_cards.card_types as types\n\ntext_block: TextBlock = TextBlock(\n    text=\"It's your third card\"\n    color=types.Colors.ACCENT,\n    size=types.FontSize.EXTRA_LARGE,\n    horizontal_alignment=types.HorizontalAlignment.CENTER,\n)\n\nimage: Image = Image(url=\"https://adaptivecards.io/content/bf-logo.png\")\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_items([text_block, image]) \\\n                                 .create()\n\n# Alternatively, you can also chain multiple add_item(...) functions:\n# card = AdaptiveCard.new() \\\n#                    .version(version) \\\n#                    .add_item(text_block) \\\n#                    .add_item(image) \\\n#                    .create()\n\n\nwith open(\"path/to/out/file.json\", \"w+\") as f:\n    f.write(card.to_json())\n```\n\nThis will result in a card like shown below.\n\n![simple card 2](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card_2.jpg?raw=true)\n\n### Finally, a more complex card\n\nYou can have a look on the following example for getting an idea of what's actually possible\nwith adaptive cards. \n\n![wrap up card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/wrap_up_card/wrap_up_card.jpg?raw=true)\n\n<details>\n<summary>Code</summary>\n\n```python\nimport adaptive_cards.card_types as types\nfrom adaptive_cards.actions import ActionToggleVisibility, TargetElement\nfrom adaptive_cards.validation import SchemaValidator, Result\nfrom adaptive_cards.card import AdaptiveCard\nfrom adaptive_cards.elements import TextBlock, Image\nfrom adaptive_cards.containers import Container, ContainerTypes, ColumnSet, Column\n\ncontainers: list[ContainerTypes] = []\n\nicon_source: str = \"https://icons8.com/icon/vNXFqyQtOSbb/launch\"\nicon_url: str = \"https://img.icons8.com/3d-fluency/94/launched-rocket.png\"\n\nheader_column_set: ColumnSet = ColumnSet(\n    columns=[\n        Column(\n            items=[\n                TextBlock(text=\"Your Daily Wrap-Up\", size=types.FontSize.EXTRA_LARGE)\n            ],\n            width=\"stretch\",\n        ),\n        Column(items=[Image(url=icon_url, width=\"40px\")], rtl=True, width=\"auto\"),\n    ]\n)\ncontainers.append(\n    Container(\n        items=[header_column_set], style=types.ContainerStyle.EMPHASIS, bleed=True\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=\"**Some numbers for you**\",\n                size=types.FontSize.MEDIUM,\n            ),\n            ColumnSet(\n                columns=[\n                    Column(\n                        items=[\n                            TextBlock(text=\"_Total_\"),\n                            TextBlock(text=\"_Done by you_\"),\n                            TextBlock(text=\"_Done by other teams_\"),\n                            TextBlock(text=\"_Still open_\"),\n                            TextBlock(text=\"_Closed_\"),\n                        ]\n                    ),\n                    Column(\n                        items=[\n                            TextBlock(text=\"5\"),\n                            TextBlock(text=\"4\"),\n                            TextBlock(text=\"3\"),\n                            TextBlock(text=\"6\"),\n                            TextBlock(text=\"1\"),\n                        ],\n                        spacing=types.Spacing.MEDIUM,\n                        rtl=True,\n                    ),\n                ],\n                separator=True,\n            ),\n        ],\n        spacing=types.Spacing.MEDIUM,\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=\"**Detailed Results**\",\n                size=types.FontSize.MEDIUM,\n            ),\n        ],\n        separator=True,\n        spacing=types.Spacing.EXTRA_LARGE,\n    )\n)\n\nsample_column_set: ColumnSet = ColumnSet(\n    columns=[\n        Column(items=[TextBlock(text=\"12312\")]),\n        Column(items=[TextBlock(text=\"done\", color=types.Colors.GOOD)]),\n        Column(items=[TextBlock(text=\"abc\")]),\n        Column(\n            items=[\n                Image(\n                    url=\"https://adaptivecards.io/content/down.png\",\n                    width=\"20px\",\n                    horizontal_alignment=types.HorizontalAlignment.RIGHT,\n                )\n            ],\n            select_action=ActionToggleVisibility(\n                title=\"More\",\n                target_elements=[\n                    TargetElement(\n                        element_id=\"toggle-me\",\n                    )\n                ],\n            ),\n        ),\n    ]\n)\n\ncontainers.append(\n    Container(\n        items=[\n            Container(\n                items=[\n                    ColumnSet(\n                        columns=[\n                            Column(items=[TextBlock(text=\"**Number**\")]),\n                            Column(items=[TextBlock(text=\"**Status**\")]),\n                            Column(items=[TextBlock(text=\"**Topic**\")]),\n                            Column(items=[TextBlock(text=\"\")]),\n                        ],\n                        id=\"headline\",\n                    ),\n                ],\n                style=types.ContainerStyle.EMPHASIS,\n                bleed=True,\n            ),\n            Container(items=[sample_column_set]),\n            Container(\n                items=[\n                    TextBlock(\n                        text=\"_Here you gonna find more information about the whole topic_\",\n                        id=\"toggle-me\",\n                        is_visible=False,\n                        is_subtle=True,\n                        wrap=True,\n                    )\n                ]\n            ),\n        ],\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=f\"Icon used from: {icon_source}\",\n                size=types.FontSize.SMALL,\n                horizontal_alignment=types.HorizontalAlignment.CENTER,\n                is_subtle=True,\n            )\n        ]\n    )\n)\n\ncard = AdaptiveCard.new().version(\"1.5\").add_items(containers).create()\n\nvalidator: SchemaValidator = SchemaValidator()\nresult: Result = validator.validate(card)\n\nprint(f\"Validation was successful: {result == Result.SUCCESS}\")\n\n```\n\n</details>\n\n<details>\n<summary>Schema</summary>\n\n```json\n{\n    \"type\": \"AdaptiveCard\",\n    \"version\": \"1.5\",\n    \"schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n    \"body\": [\n        {\n            \"items\": [\n                {\n                    \"type\": \"ColumnSet\",\n                    \"columns\": [\n                        {\n                            \"items\": [\n                                {\n                                    \"text\": \"Your Daily Wrap-Up\",\n                                    \"type\": \"TextBlock\",\n                                    \"size\": \"extraLarge\"\n                                }\n                            ],\n                            \"width\": \"stretch\"\n                        },\n                        {\n                            \"items\": [\n                                {\n                                    \"url\": \"https://img.icons8.com/3d-fluency/94/launched-rocket.png\",\n                                    \"type\": \"Image\",\n                                    \"width\": \"40px\"\n                                }\n                            ],\n                            \"rtl\": true,\n                            \"width\": \"auto\"\n                        }\n                    ]\n                }\n            ],\n            \"type\": \"Container\",\n            \"style\": \"emphasis\",\n            \"bleed\": true\n        },\n        {\n            \"spacing\": \"medium\",\n            \"items\": [\n                {\n                    \"text\": \"**Some numbers for you**\",\n                    \"type\": \"TextBlock\",\n                    \"size\": \"medium\"\n                },\n                {\n                    \"separator\": true,\n                    \"type\": \"ColumnSet\",\n                    \"columns\": [\n                        {\n                            \"items\": [\n                                {\n                                    \"text\": \"_Total_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Done by you_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Done by other teams_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Still open_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Closed_\",\n                                    \"type\": \"TextBlock\"\n                                }\n                            ]\n                        },\n                        {\n                            \"spacing\": \"medium\",\n                            \"items\": [\n                                {\n                                    \"text\": \"5\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"4\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"3\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"6\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"1\",\n                                    \"type\": \"TextBlock\"\n                                }\n                            ],\n                            \"rtl\": true\n                        }\n                    ]\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"separator\": true,\n            \"spacing\": \"extraLarge\",\n            \"items\": [\n                {\n                    \"text\": \"**Detailed Results**\",\n                    \"type\": \"TextBlock\",\n                    \"size\": \"medium\"\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"items\": [\n                {\n                    \"items\": [\n                        {\n                            \"id\": \"headline\",\n                            \"type\": \"ColumnSet\",\n                            \"columns\": [\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Number**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Status**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Topic**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                }\n                            ]\n                        }\n                    ],\n                    \"type\": \"Container\",\n                    \"style\": \"emphasis\",\n                    \"bleed\": true\n                },\n                {\n                    \"items\": [\n                        {\n                            \"type\": \"ColumnSet\",\n                            \"columns\": [\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"12312\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"done\",\n                                            \"type\": \"TextBlock\",\n                                            \"color\": \"good\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"abc\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"url\": \"https://adaptivecards.io/content/down.png\",\n                                            \"type\": \"Image\",\n                                            \"horizontalAlignment\": \"right\",\n                                            \"width\": \"20px\"\n                                        }\n                                    ],\n                                    \"selectAction\": {\n                                        \"title\": \"More\",\n                                        \"targetElements\": [\n                                            {\n                                                \"elementId\": \"toggle-me\"\n                                            }\n                                        ],\n                                        \"type\": \"Action.ToggleVisibility\"\n                                    }\n                                }\n                            ]\n                        }\n                    ],\n                    \"type\": \"Container\"\n                },\n                {\n                    \"items\": [\n                        {\n                            \"id\": \"toggle-me\",\n                            \"isVisible\": false,\n                            \"text\": \"_Here you gonna find more information about the whole topic_\",\n                            \"type\": \"TextBlock\",\n                            \"isSubtle\": true,\n                            \"wrap\": true\n                        }\n                    ],\n                    \"type\": \"Container\"\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"items\": [\n                {\n                    \"text\": \"Icon used from: https://icons8.com/icon/vNXFqyQtOSbb/launch\",\n                    \"type\": \"TextBlock\",\n                    \"horizontalAlignment\": \"center\",\n                    \"isSubtle\": true,\n                    \"size\": \"small\"\n                }\n            ],\n            \"type\": \"Container\"\n        }\n    ]\n}\n```\n\n\n</details>\n\nBut we are still scratching the surface. You can do even better!\n\n\n\n### Validate schema\n\nNew components and fields are getting introduced every now and then. This means, if you are using an early version for a card and add fields, which are not compliant with it, you will have an invalid schema. To prevent you from exporting fields not yet supported by the card and target framework, a schema validation can be performed. It's as simple as that:\n\n```Python\nfrom adaptive_cards.validator import SchemaValidator, Result\n\n...\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_items([text_block, image]) \\\n                                 .create()\n\nvalidator: SchemaValidator = SchemaValidator()\nresult: Result = validator.validate(card)\n\nprint(f\"Validation was successful: {result == Result.SUCCESS}\")\n\n```\n\n## Examples\n\nIf you are interested in more comprehensive examples or the actual source code, have a look into the `examples` folder. \n\n## Contribution\n\nFeel free to create issues, fork the repository or even come up with a pull request. I am happy about any kind of contribution and would love\nto hear your feedback! \n\n## Roadmap\n\n- [x] \ud83d\udcd5 Comprehensive documentation on code level\n- [x] \ud83d\udc0d Ready to use Python package\n- [ ] \ud83d\ude80 More and better examples\n- [ ] \ud83d\udd0e Comprehensive validation\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Dennis Eder  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Python wrapper library for building beautiful adaptive cards",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/dennis6p/adaptive-cards-py"
    },
    "split_keywords": [
        "bot",
        "ui",
        "adaptivecards",
        "cards",
        "adaptivecardsio",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "594b2815a32583ac1bd229cdf86a6943e4520bbb354cb6ed6b38e9bf07be2b4b",
                "md5": "3b6c1c7291a25964a0f55f2211c3a7fc",
                "sha256": "1010ab218d9da5c09e5d637fad8d83f1df467c5c1890d4dc96028df4ac1f231b"
            },
            "downloads": -1,
            "filename": "adaptive_cards_py-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b6c1c7291a25964a0f55f2211c3a7fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 20865,
            "upload_time": "2023-12-23T18:41:19",
            "upload_time_iso_8601": "2023-12-23T18:41:19.044681Z",
            "url": "https://files.pythonhosted.org/packages/59/4b/2815a32583ac1bd229cdf86a6943e4520bbb354cb6ed6b38e9bf07be2b4b/adaptive_cards_py-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6926a014c1d67be6ad718f4f08b74753ec9909324774fe22220470fde4545ace",
                "md5": "3cecd00a5a23d2d521dd1ae735571c5b",
                "sha256": "7d1a889b9f276c203617e3f62f23ac3ba23427a94363f11888b95856301f18dc"
            },
            "downloads": -1,
            "filename": "adaptive-cards-py-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "3cecd00a5a23d2d521dd1ae735571c5b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 42506,
            "upload_time": "2023-12-23T18:41:20",
            "upload_time_iso_8601": "2023-12-23T18:41:20.782165Z",
            "url": "https://files.pythonhosted.org/packages/69/26/a014c1d67be6ad718f4f08b74753ec9909324774fe22220470fde4545ace/adaptive-cards-py-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-23 18:41:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dennis6p",
    "github_project": "adaptive-cards-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "adaptive-cards-py"
}
        
Elapsed time: 0.15045s