webex-space-purge
Overview
Purge all users from a space who have not posted a message since a specified cut-off date.
This can help pare down space membership when approaching the 5K limit.
Components used:
Tested using:
- OS: Ubuntu Linux 22.04
- Python: 3.10.4
Webex for Developers Site
Getting started
-
Install Python 3.10+
On Windows, choose the option to add to PATH environment variable
-
The project was built/tested using Visual Studio Code
On first launch of VS Code, install the Python plugin
-
Clone this repo to a directory on your PC:
git clone https://github.com/CiscoDevNet/webex-space-purge.git
cd webex-space-purge
-
(Optional) Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate
-
Dependency Installation:
pip install -r requirements.txt
-
Open the project in VS Code:
-
Visit [https://developer.webex.com/docs/getting-started#accounts-and-authentication), login, and copy your personal access token
-
In Visual Studio Code:
-
Rename .env.example
to .env
and edit to configure
-
For absolute safety, line 105 in webex_space_purge.py is commented out:
# api.memberships.delete(row['id'])
Uncomment this line to arm the code for real purging!
-
Press F5 to run the application
or
python webex_space_purge.py
-
After messages/memberships are retrieved and the list of users to be purged is tallied, the target Webex user emails will be written to purge_list.txt
.
You may want to examine this file as a sanity check before proceeding.
-
Finally: you will be asked to type in CONFIRM
before any users are actually purged.
Note: If something goes wrong, it should theoretically be possible to recreate purged the memberships based on the purge_list.txt
file.