Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/user/cards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Webex supports `AdaptiveCards <https://www.adaptivecards.io/>`_ to allow
new levels of interactivity for bots and integrations. You can read more about
how cards and buttons work `in the official guide <https://developer.webex.com/docs/api/guides/cards>`_.

In this guide I want to cover the abstraction built into the webexpythonsdk that
In this guide we want to cover the abstraction built into the webexpythonsdk that
lets you author adaptive cards in pure python without having to touch the
underlying JSON of an adaptive card.

Expand All @@ -22,7 +22,7 @@ Lets dive into a simple example that sends a card to a room
from webexpythonsdk import WebexAPI
from webexpythonsdk.models.cards.card import AdaptiveCard
from webexpythonsdk.models.cards.inputs import Text, Number
from webexpythonsdk.models.cards.components import TextBlock
from webexpythonsdk.models.cards.card_elements import TextBlock
from webexpythonsdk.models.cards.actions import Submit

greeting = TextBlock("Hey hello there! I am a adaptive card")
Expand Down
82 changes: 79 additions & 3 deletions docs/user/migrate.rst
Copy link

@Sakthivel-Ramasamy Sakthivel-Ramasamy Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change the import from webexpythonsdk.models.cards.xxxxxx import xxxxxx to from webexpythonsdk.models.cards import xxxxxx which makes the import from __init__.py module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sakthivel-Ramasamy sounds like a good idea. Maybe raise a new issue on it, and code it or allow the community to pick it up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashjorda , this functionality is already available in the SDK. I am using it for many months now :)

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Migration

This *should* 🤞 be easy!

``webexpythonsdk`` is designed to be a drop-in replacement for the ``webexteamssdk`` package. The SDK interface and data objects are largely unchanged with only a few minor name changes.
The transition from `webexteamssdk` to `webexpythonsdk` is not entirely a "drop-in replacement" due to substantial changes in class structures and functionalities. This guide aims to clarify these changes and offer solutions to ease the migration process.

Major changes that you should be aware of:

Expand All @@ -17,7 +17,6 @@ Major changes that you should be aware of:
* The primary API object has changed from ``WebexTeamsAPI`` to ``WebexAPI``



---------------
Migration Guide
---------------
Expand All @@ -39,7 +38,9 @@ The following table summarizes the name changes that need to be made to migrate

*Note:* The old ``WEBEX_TEAMS_ACCESS_TOKEN`` environment variable should continue to work with the new package; however, you will receive a deprecation warning. It is recommended to update the environment variable name to ``WEBEX_ACCESS_TOKEN``.

**Doing a quick search-and-replace in your codebase should be all you need to do to migrate.**


**Doing a quick search-and-replace in your codebase will help when migrating.**

Detailed Steps
--------------
Expand All @@ -64,6 +65,80 @@ Detailed Steps

**Primary API Object:** Replace all instances of ``WebexTeamsAPI`` with ``WebexAPI``.

Key Changes For Adaptive Cards
------------------------------

Module and Class Changes
~~~~~~~~~~~~~~~~~~~~~~~~

The following table outlines the changes in module and class names:

.. list-table::
:widths: 25 25 50
:header-rows: 1

* - Old Module/Class
- New Module/Class
- Example Usage
* - `webexteamssdk.models.cards.components.TextBlock`
- `webexpythonsdk.models.cards.card_elements.TextBlock`
- `TextBlock(color=Colors.light)`
* - `webexteamssdk.models.cards.container.ColumnSet`
- `webexpythonsdk.models.cards.containers.ColumnSet`
- `ColumnSet(columns=[Column()])`
* - `webexteamssdk.models.cards.components.Image`
- `webexpythonsdk.models.cards.card_elements.Image`
- `Image(url="https://example.com/image.jpg")`
* - `webexteamssdk.models.cards.components.Choice`
- `webexpythonsdk.models.cards.inputs.Choice`
- `Choice(title="Option", value="option")`
* - `webexteamssdk.models.cards.options.BlockElementHeight`
- `webexpythonsdk.models.cards.options.BlockElementHeight`
- `BlockElementHeight(height="stretch")`
* - New Imports
- `webexpythonsdk.models.cards.actions.OpenUrl`, `Submit`, `ShowCard`
- `OpenUrl(url="https://example.com")`
* - New Imports
- `webexpythonsdk.models.cards.types.BackgroundImage`
- `BackgroundImage(url="https://example.com/image.jpg")`

Enums and Case Sensitivity
~~~~~~~~~~~~~~~~~~~~~~~~~~

Attributes now require specific enums for values, which are case-sensitive. For example:

- **Previous**: `TextBlock.color = "Light"`
- **New**: `TextBlock.color = Colors.light`

Refer to the `Adaptive Cards TextBlock documentation <https://adaptivecards.io/explorer/TextBlock.html>`_ for valid enum values.

Compatibility Solutions
-----------------------

Wrapper Classes
~~~~~~~~~~~~~~~

To facilitate backward compatibility, consider using the following wrapper classes:

.. code-block:: python

# Example wrapper for components.py
from webexpythonsdk.models.cards.card_elements import TextBlock, Image
from webexpythonsdk.models.cards.containers import Column, Fact

# Example wrapper for container.py
from webexpythonsdk.models.cards.containers import Container, ColumnSet, FactSet

Module Flag for Compatibility
-----------------------------

A module flag can be introduced to bypass the `validate_input` function where backward compatibility is needed. Ensure this flag is set before executing legacy code.

.. code-block:: python

# Example usage
webexpythonsdk.enable_backward_compatibility(True)

----------------
For Contributors
----------------
Expand Down Expand Up @@ -95,6 +170,7 @@ Project changes that you should be aware of:
+-------------------------------------+-------------------------------+



*Copyright (c) 2016-2024 Cisco and/or its affiliates.*


Expand Down