Skip to content

Commit c2decd2

Browse files
authored
updated migration doc and cards doc (#254)
Updated documentation per migration issue [252](#252)
2 parents 8d26a00 + 86dc866 commit c2decd2

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed

docs/user/cards.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Webex supports `AdaptiveCards <https://www.adaptivecards.io/>`_ to allow
88
new levels of interactivity for bots and integrations. You can read more about
99
how cards and buttons work `in the official guide <https://developer.webex.com/docs/api/guides/cards>`_.
1010

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

@@ -22,7 +22,7 @@ Lets dive into a simple example that sends a card to a room
2222
from webexpythonsdk import WebexAPI
2323
from webexpythonsdk.models.cards.card import AdaptiveCard
2424
from webexpythonsdk.models.cards.inputs import Text, Number
25-
from webexpythonsdk.models.cards.components import TextBlock
25+
from webexpythonsdk.models.cards.card_elements import TextBlock
2626
from webexpythonsdk.models.cards.actions import Submit
2727
2828
greeting = TextBlock("Hey hello there! I am a adaptive card")

docs/user/migrate.rst

+79-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Migration
88

99
This *should* 🤞 be easy!
1010

11-
``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.
11+
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.
1212

1313
Major changes that you should be aware of:
1414

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

1919

20-
2120
---------------
2221
Migration Guide
2322
---------------
@@ -39,7 +38,9 @@ The following table summarizes the name changes that need to be made to migrate
3938

4039
*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``.
4140

42-
**Doing a quick search-and-replace in your codebase should be all you need to do to migrate.**
41+
42+
43+
**Doing a quick search-and-replace in your codebase will help when migrating.**
4344

4445
Detailed Steps
4546
--------------
@@ -64,6 +65,80 @@ Detailed Steps
6465

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

68+
Key Changes For Adaptive Cards
69+
------------------------------
70+
71+
Module and Class Changes
72+
~~~~~~~~~~~~~~~~~~~~~~~~
73+
74+
The following table outlines the changes in module and class names:
75+
76+
.. list-table::
77+
:widths: 25 25 50
78+
:header-rows: 1
79+
80+
* - Old Module/Class
81+
- New Module/Class
82+
- Example Usage
83+
* - `webexteamssdk.models.cards.components.TextBlock`
84+
- `webexpythonsdk.models.cards.card_elements.TextBlock`
85+
- `TextBlock(color=Colors.light)`
86+
* - `webexteamssdk.models.cards.container.ColumnSet`
87+
- `webexpythonsdk.models.cards.containers.ColumnSet`
88+
- `ColumnSet(columns=[Column()])`
89+
* - `webexteamssdk.models.cards.components.Image`
90+
- `webexpythonsdk.models.cards.card_elements.Image`
91+
- `Image(url="https://example.com/image.jpg")`
92+
* - `webexteamssdk.models.cards.components.Choice`
93+
- `webexpythonsdk.models.cards.inputs.Choice`
94+
- `Choice(title="Option", value="option")`
95+
* - `webexteamssdk.models.cards.options.BlockElementHeight`
96+
- `webexpythonsdk.models.cards.options.BlockElementHeight`
97+
- `BlockElementHeight(height="stretch")`
98+
* - New Imports
99+
- `webexpythonsdk.models.cards.actions.OpenUrl`, `Submit`, `ShowCard`
100+
- `OpenUrl(url="https://example.com")`
101+
* - New Imports
102+
- `webexpythonsdk.models.cards.types.BackgroundImage`
103+
- `BackgroundImage(url="https://example.com/image.jpg")`
104+
105+
Enums and Case Sensitivity
106+
~~~~~~~~~~~~~~~~~~~~~~~~~~
107+
108+
Attributes now require specific enums for values, which are case-sensitive. For example:
109+
110+
- **Previous**: `TextBlock.color = "Light"`
111+
- **New**: `TextBlock.color = Colors.light`
112+
113+
Refer to the `Adaptive Cards TextBlock documentation <https://adaptivecards.io/explorer/TextBlock.html>`_ for valid enum values.
114+
115+
Compatibility Solutions
116+
-----------------------
117+
118+
Wrapper Classes
119+
~~~~~~~~~~~~~~~
120+
121+
To facilitate backward compatibility, consider using the following wrapper classes:
122+
123+
.. code-block:: python
124+
125+
# Example wrapper for components.py
126+
from webexpythonsdk.models.cards.card_elements import TextBlock, Image
127+
from webexpythonsdk.models.cards.containers import Column, Fact
128+
129+
# Example wrapper for container.py
130+
from webexpythonsdk.models.cards.containers import Container, ColumnSet, FactSet
131+
132+
Module Flag for Compatibility
133+
-----------------------------
134+
135+
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.
136+
137+
.. code-block:: python
138+
139+
# Example usage
140+
webexpythonsdk.enable_backward_compatibility(True)
141+
67142
----------------
68143
For Contributors
69144
----------------
@@ -95,6 +170,7 @@ Project changes that you should be aware of:
95170
+-------------------------------------+-------------------------------+
96171

97172

173+
98174
*Copyright (c) 2016-2024 Cisco and/or its affiliates.*
99175

100176

0 commit comments

Comments
 (0)