### Setup development environment Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/contributing.rst.txt Command to install project dependencies using the Makefile setup target. ```bash make setup ``` -------------------------------- ### Install Webex Python SDK using PIP Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/index.html Use this command to install the Webex Python SDK. Ensure you have pip installed. ```bash pip install webex-python-sdk ``` -------------------------------- ### Clone and Install from Source Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/installation.rst.txt Commands to download the repository from GitHub and install it locally. ```bash $ git clone https://github.com/WebexCommunity/WebexPythonSDK.git ``` ```bash $ python setup.py install ``` -------------------------------- ### Install WebexPythonSDK Package Source: https://webexcommunity.github.io/WebexPythonSDK/installation.html Execute this command to install the package into your local environment after cloning. ```bash $ python setup.py install ``` -------------------------------- ### Uninstall and Install webexpythonsdk Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/migrate.rst.txt Use these bash commands to uninstall the old SDK and install the new one. ```bash pip uninstall webexteamssdk pip install webexpythonsdk ``` -------------------------------- ### Install poetry Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/contributing.rst.txt Command to install the poetry dependency manager. ```bash pip install poetry ``` -------------------------------- ### Installation and Upgrade Source: https://webexcommunity.github.io/WebexPythonSDK/installation.html Commands to install or upgrade the webexpythonsdk library in your Python environment. ```APIDOC ## Installation ### Description Install the webexpythonsdk package using pip. ### Command `pip install webexpythonsdk` ## Upgrade ### Description Upgrade the existing webexpythonsdk package to the latest version. ### Command `pip install webexpythonsdk --upgrade` ``` -------------------------------- ### Install webexpythonsdk via PIP Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/installation.rst.txt Use this command to install the package from the Python Package Index. ```bash $ pip install webexpythonsdk ``` -------------------------------- ### Python Wrapper Class Example Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/migrate.rst.txt Example Python code demonstrating wrapper classes for backward compatibility with Adaptive Cards components and containers. ```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 ``` -------------------------------- ### Create ShowCard Action Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a 'Show Card' action that reveals another card when clicked. ```python from webexpythonsdk.cards import ShowCard, Text # Define the card to be shown secondary_card = { "type": "AdaptiveCard", "body": [ Text(text="This is the secondary card.") ] } # Create the ShowCard action show_card_action = ShowCard(title='Show Details', card=secondary_card) ``` -------------------------------- ### Create OpenUrl Action Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating an action that opens a URL when clicked in a Webex card. ```python from webexpythonsdk.cards import OpenUrl open_url_action = OpenUrl(title='Visit Webex', url='https://web.webex.com/') ``` -------------------------------- ### Create Toggle Input Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a toggle (switch) input for a Webex card. ```python from webexpythonsdk.cards import Toggle toggle_input = Toggle(id='subscribe', title='Subscribe to newsletter', value=False) ``` -------------------------------- ### Create Date Input Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a date input field for a Webex card. ```python from webexpythonsdk.cards import Date date_input = Date(id='meetingDate', title='Select a date') ``` -------------------------------- ### Create Time Input Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a time input field for a Webex card. ```python from webexpythonsdk.cards import Time time_input = Time(id='meetingTime', title='Select a time') ``` -------------------------------- ### Create OpenUrl Action for Cards Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/index.html Example of defining an action that opens a URL when clicked in an adaptive card. ```python from webex_python_sdk.models.cards import OpenUrl open_url_action = OpenUrl(title="Visit Webex", url="https://web.webex.com") ``` -------------------------------- ### Create Number Input Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a number input field for a Webex card. ```python from webexpythonsdk.cards import Number number_input = Number(id='quantity', value=1, min=0, max=100) ``` -------------------------------- ### Create Text Input Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a text input field for a Webex card. ```python from webexpythonsdk.cards import Text text_input = Text(id='name', placeholder='Enter your name', isRequired=True) ``` -------------------------------- ### Upgrade webexpythonsdk using PIP Source: https://webexcommunity.github.io/WebexPythonSDK/installation.html Run this command to check for and install the latest version of the webexpythonsdk package. ```bash pip install webexpythonsdk --upgrade ``` -------------------------------- ### Create Date Input for Cards Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/index.html Example of defining a date input field within an adaptive card. ```python from webex_python_sdk.models.cards import Date date_input = Date(id="birthdate", title="Your Birthdate") ``` -------------------------------- ### Create Time Input for Cards Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/index.html Example of defining a time input field within an adaptive card. ```python from webex_python_sdk.models.cards import Time time_input = Time(id="meeting_time", title="Meeting Time") ``` -------------------------------- ### Sending and Processing Cards Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/guest_issuer.html Guides on how to send cards to Webex and process actions triggered by users. ```APIDOC ## Sending and Processing Cards ### Description This section provides guidance on how to send interactive cards to Webex and how to handle the actions users take on these cards. ### Sending a Card - Use the appropriate SDK methods to construct and send card payloads to Webex. ### Processing a Card Action - Implement logic to receive and process the data submitted when a user interacts with a card action (e.g., a submit button). ``` -------------------------------- ### Initialize WebexAPI with Manual Token Source: https://webexcommunity.github.io/WebexPythonSDK/user/quickstart.html Provide the access token directly as an argument to the WebexAPI constructor. ```python >>> from webexpythonsdk import WebexAPI >>> api = WebexAPI(access_token='lkj345w...') ``` -------------------------------- ### GET /rooms/{roomId}/meetingInfo Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html Get the meeting details for a specific room. ```APIDOC ## GET /rooms/{roomId}/meetingInfo ### Description Get the meeting details for a room, such as the SIP address, meeting URL, and dial-in numbers. ### Method GET ### Endpoint /rooms/{roomId}/meetingInfo ### Parameters #### Path Parameters - **roomId** (str) - Required - The unique identifier for the room. ### Response #### Success Response (200) - **RoomMeetingInfo** - Object containing meeting details. ``` -------------------------------- ### Authentication and Initialization Source: https://webexcommunity.github.io/WebexPythonSDK/user/quickstart.html Explains how to obtain a personal access token and initialize the WebexAPI connection object. ```APIDOC ## Authentication and Initialization ### Description To interact with the Webex APIs, you must have a Webex Access Token. This token validates access and identifies the requesting user. The `WebexAPI` class serves as the main connection object. ### Method Initialization ### Parameters #### Request Body - **access_token** (string) - Required - The personal access token obtained from developer.webex.com ### Request Example ```python from webexpythonsdk import WebexAPI # Initialize the connection object api = WebexAPI(access_token="YOUR_ACCESS_TOKEN") ``` ### Response #### Success Response (Object) - **api** (WebexAPI) - An initialized connection object ready to make API calls. ``` -------------------------------- ### WebexAPI Initialization Source: https://webexcommunity.github.io/WebexPythonSDK/user/migrate.html The primary entry point for the SDK is the WebexAPI class, which manages authentication and provides access to all service modules. ```APIDOC ## WebexAPI Initialization ### Description Initializes the main connection object to interact with Webex APIs. ### Method Constructor ### Parameters #### Request Body - **access_token** (string) - Required - The Webex access token for authentication. - **single_request_timeout** (int) - Optional - Timeout for individual API requests. - **wait_on_rate_limit** (bool) - Optional - Whether to automatically wait when rate limits are hit. ### Request Example from webexpythonsdk import WebexAPI api = WebexAPI(access_token="YOUR_ACCESS_TOKEN") ``` -------------------------------- ### Run Webex Python SDK Tests Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/teams.html Instructions for running the test suite locally. This is crucial for verifying your changes and ensuring the SDK functions correctly. ```bash pytest ``` -------------------------------- ### Rooms API Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List, create, get, update, delete rooms, and get room meeting info. ```APIDOC ## Rooms API ### Description Endpoints for managing rooms, including listing, creating, retrieving, updating, deleting, and getting room meeting information. ### Method `rooms.list()` `rooms.create()` `rooms.get()` `rooms.get_meeting_info()` `rooms.update()` `rooms.delete()` ### Endpoint `/rooms` (Conceptual - actual endpoint depends on SDK implementation) ### Parameters #### Path Parameters None #### Query Parameters (for list) * **type** (str) - Optional - Filter rooms by type (e.g., 'direct', 'conversation'). * **sortBy** (str) - Optional - Field to sort by (e.g., 'lastActivity'). * **max** (int) - Optional - The maximum number of rooms to return. #### Request Body (for create) * **title** (str) - Required - The title of the room. * **isPrivate** (bool) - Optional - Whether the room is private. Defaults to false. * **ownerId** (str) - Optional - The ID of the owner of the room. #### Request Body (for update) * **title** (str) - Optional - The updated title of the room. ### Request Example ```python # Assuming 'api' is an initialized WebexAPI object # List rooms # all_rooms = api.rooms.list() # Create a new room # new_room = api.rooms.create(title='Project Discussion') # Get a specific room # room_details = api.rooms.get(roomId='ROOM_ID') # Get meeting info for a room # meeting_info = api.rooms.get_meeting_info(roomId='ROOM_ID') # Update a room title # updated_room = api.rooms.update(roomId='ROOM_ID', title='Updated Project Title') # Delete a room # api.rooms.delete(roomId='ROOM_ID') ``` ### Response #### Success Response (200) * **id** (str) - The ID of the room. * **title** (str) - The title of the room. * **isPrivate** (bool) - Whether the room is private. * **ownerId** (str) - The ID of the owner. * **created** (str) - The timestamp when the room was created. #### Response Example ```json { "id": "ROOM_ID", "title": "Project Discussion", "isPrivate": false, "ownerId": "OWNER_ID", "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### WebexAPI __init__ Method Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/rooms.html Initializes the WebexAPI object. Requires an access token for authentication. ```python def __init__(self, access_token: str, **kwargs): pass ``` -------------------------------- ### Webex User Data Object Example (JSON) Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/quickstart.rst.txt This is an example of a JSON data object returned by the Webex API, representing a user's profile information. ```json { "displayName": "Chris Lunsford", "firstName": "Chris", "created": "2012-06-15T20:36:48.914Z", "lastName": "Lunsford", "emails": [ "cm@lunsford.io" ], "avatar": "https://1efa7a94ed216783e352-c62266528714497a17239ececf39e9e2.ssl.cf1.rackcdn.com/V1~ba1ecf557a7e0b7cc3081998df965aad~7-HrvYOJSQ6eJgWJuFVbzg==~1600", "id": "Y2lzY29zcGFyazovL3VzL1BFT1BMRS9mZjhlZTZmYi1hZmVmLTRhNGQtOTJiMS1kNmIyMTZiNTg5NDk" } ``` -------------------------------- ### Create and activate virtual environment Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/contributing.rst.txt Commands to initialize a Python virtual environment and activate it based on the operating system. ```bash python3 -m venv venv # On Mac/Linux source venv/bin/activate # On Windows venv\Scripts\activate.bat ``` -------------------------------- ### Messages API Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List, create, get, and delete messages. ```APIDOC ## Messages API ### Description Endpoints for managing messages in rooms, including listing, creating, retrieving, and deleting them. ### Method `messages.list()` `messages.list_direct()` `messages.create()` `messages.get()` `messages.delete()` ### Endpoint `/messages` (Conceptual - actual endpoint depends on SDK implementation) ### Parameters #### Path Parameters None #### Query Parameters (for list) * **roomId** (str) - Optional - Filter messages by room ID. * **before** (str) - Optional - Filter messages before a specific message ID. * **beforeMessage** (str) - Optional - Filter messages before a specific timestamp (ISO 8601 format). * **max** (int) - Optional - The maximum number of messages to return. #### Query Parameters (for list_direct) * **personId** (str) - Optional - Filter direct messages by person ID. * **personEmail** (str) - Optional - Filter direct messages by person email. #### Request Body (for create) * **roomId** (str) - Required - The ID of the room to send the message to. * **text** (str) - Required - The content of the message. * **parentId** (str) - Optional - The ID of the parent message if this is a reply. ### Request Example ```python # Assuming 'api' is an initialized WebexAPI object # List messages in a room # room_messages = api.messages.list(roomId='ROOM_ID', max=10) # Send a message to a room # sent_message = api.messages.create( # roomId='ROOM_ID', # text='Hello, Webex!' # ) # Get a specific message # message_details = api.messages.get(messageId='MESSAGE_ID') # Delete a message # api.messages.delete(messageId='MESSAGE_ID') ``` ### Response #### Success Response (200) * **id** (str) - The ID of the message. * **roomId** (str) - The ID of the room. * **roomType** (str) - The type of the room. * **text** (str) - The content of the message. * **personId** (str) - The ID of the sender. * **personEmail** (str) - The email of the sender. * **created** (str) - The timestamp when the message was created. #### Response Example ```json { "id": "MESSAGE_ID", "roomId": "ROOM_ID", "roomType": "direct", "text": "Hello, Webex!", "personId": "SENDER_ID", "personEmail": "sender@example.com", "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### GET /roles Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/roles.html List all roles available in the Webex environment. ```APIDOC ## GET /roles ### Description List all roles available in the Webex environment. ### Method GET ### Endpoint /roles ### Parameters #### Query Parameters - **request_parameters** (dict) - Optional - Additional request parameters for future support. ``` -------------------------------- ### Initialize WebexAPI with Access Token Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api.html Instantiate the WebexAPI client using an access token. The token can be provided directly or retrieved from the WEBEX_ACCESS_TOKEN environment variable. This method is suitable for direct API access when an OAuth flow has already been completed. ```python access_token = access_token or WEBEX_ACCESS_TOKEN # Init AccessTokensAPI wrapper early to use for oauth requests self.access_tokens = AccessTokensAPI( base_url, object_factory, single_request_timeout=single_request_timeout, ) # Check if the user has provided the required oauth parameters oauth_param_list = [client_id, client_secret, oauth_code, redirect_uri] if not access_token and all(oauth_param_list): access_token = self.access_tokens.get( client_id=client_id, client_secret=client_secret, code=oauth_code, redirect_uri=redirect_uri, ).access_token # Set optional API metrics tracking variables from env vars if there be_geo_id = be_geo_id or os.environ.get("BE_GEO_ID") caller = caller or os.environ.get("WEBEX_PYTHON_SDK_CALLER") # If an access token hasn't been provided as a parameter, environment # variable, or obtained via an OAuth exchange raise an error. if not access_token: raise AccessTokenError( "You must provide a Webex access token to interact with " "the Webex APIs, either via a WEBEX_ACCESS_TOKEN " "environment variable or via the access_token argument." ) # Create the API session # All of the API calls associated with a WebexAPI object will # leverage a single RESTful 'session' connecting to the Webex # cloud. self._session = RestSession( access_token=access_token, base_url=base_url, single_request_timeout=single_request_timeout, wait_on_rate_limit=wait_on_rate_limit, proxies=proxies, be_geo_id=be_geo_id, caller=caller, disable_ssl_verify=disable_ssl_verify, ) # API wrappers self.admin_audit_events = AdminAuditEventsAPI( self._session, object_factory, ) self.attachment_actions = AttachmentActionsAPI( self._session, object_factory, ) self.events = EventsAPI(self._session, object_factory) self.guest_issuer = GuestIssuerAPI(self._session, object_factory) self.licenses = LicensesAPI(self._session, object_factory) self.memberships = MembershipsAPI(self._session, object_factory) self.messages = MessagesAPI(self._session, object_factory) self.organizations = OrganizationsAPI(self._session, object_factory) self.people = PeopleAPI(self._session, object_factory) self.roles = RolesAPI(self._session, object_factory) self.rooms = RoomsAPI(self._session, object_factory) self.room_tabs = RoomTabsAPI(self._session, object_factory) self.teams = TeamsAPI(self._session, object_factory) self.team_memberships = TeamMembershipsAPI( self._session, ) ``` -------------------------------- ### Create a Message with Webex Python SDK Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/intro.rst.txt This example demonstrates creating a message using the Webex Python SDK. It simplifies the process by abstracting API calls into Python methods and handles potential API errors. The SDK automatically reads the access token from the WEBEX_ACCESS_TOKEN environment variable. ```python from webexpythonsdk import WebexAPI api = WebexAPI() try: message = api.messages.create('', text='') print("New message created, with ID:", message.id) print(message.text) except ApiError as e: print(e) ``` -------------------------------- ### GET /team/memberships Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List team memberships for a specific team by ID. ```APIDOC ## GET /team/memberships ### Description List team memberships for a team, by ID. This method supports pagination and returns a generator container. ### Method GET ### Parameters #### Query Parameters - **teamId** (str) - Required - List team memberships for a team, by ID. - **max** (int) - Optional - Limit the maximum number of items returned from the Webex service per request. ### Response #### Success Response (200) - **GeneratorContainer** (object) - Yields the team memberships returned by the Webex query. ``` -------------------------------- ### GET /rooms/{roomId} Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html Retrieve the details of a specific room by its ID. ```APIDOC ## GET /rooms/{roomId} ### Description Get the details of a room, by ID. ### Method GET ### Endpoint /rooms/{roomId} ### Parameters #### Path Parameters - **roomId** (str) - Required - The ID of the room to be retrieved. ### Response #### Success Response (200) - **Room** - A Room object with the details of the requested room. ``` -------------------------------- ### WebexAPI Initialization Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api.html Initializes the WebexAPI client with authentication credentials and configuration options. ```APIDOC ## WebexAPI Initialization ### Description Initializes the WebexAPI client. It supports authentication via an access token or an OAuth flow. Various optional parameters can be provided for customization, including base URL, timeouts, proxy settings, and SSL verification. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters for Initialization: - **access_token** (str, optional): The access token for authentication. Defaults to the WEBEX_ACCESS_TOKEN environment variable. - **base_url** (str, optional): The base URL for the Webex API. Defaults to the official Webex API endpoint. - **single_request_timeout** (int, optional): Timeout in seconds for a single API request. Defaults to 10 seconds. - **wait_on_rate_limit** (bool, optional): If True, the SDK will wait when rate limits are encountered. Defaults to False. - **client_id** (str, optional): The client ID of your integration, required for OAuth flow. - **client_secret** (str, optional): The client secret of your integration, required for OAuth flow. - **oauth_code** (str, optional): The OAuth authorization code provided by the user, required for OAuth flow. - **oauth_redirect_uri** (str, optional): The redirect URI used in the user OAuth process, required for OAuth flow. - **proxies** (dict, optional): Dictionary of proxies to be passed to the requests session. - **be_geo_id** (str, optional): Optional partner identifier for API usage tracking. Defaults to the BE_GEO_ID environment variable. - **caller** (str, optional): Optional identifier for API usage tracking. Defaults to the WEBEX_PYTHON_SDK_CALLER environment variable. - **disable_ssl_verify** (bool, optional): If True, SSL certificate verification is disabled. Defaults to False. ### Returns - **WebexAPI**: A new instance of the WebexAPI object. ### Raises - **TypeError**: If parameter types are incorrect. - **AccessTokenError**: If an access token is not provided via the `access_token` argument or an environment variable, and OAuth parameters are insufficient. ### Initialization Example (Access Token) ```python from webex_api import WebexAPI # Using an access token directly api = WebexAPI(access_token='YOUR_ACCESS_TOKEN') ``` ### Initialization Example (OAuth Flow) ```python from webex_api import WebexAPI # Using OAuth parameters to obtain an access token api = WebexAPI( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', oauth_code='AUTHORIZATION_CODE', oauth_redirect_uri='YOUR_REDIRECT_URI' ) ``` ### Initialization Example (with optional parameters) ```python from webex_api import WebexAPI api = WebexAPI( access_token='YOUR_ACCESS_TOKEN', base_url='https://api.example.com', single_request_timeout=5, wait_on_rate_limit=True, proxies={'http': 'http://proxy.example.com:8080'}, disable_ssl_verify=True ) ``` ``` -------------------------------- ### GET /licenses/{licenseId} Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html Retrieves the details of a specific license by its ID. ```APIDOC ## GET /licenses/{licenseId} ### Description Get the details of a License, by ID. ### Parameters #### Path Parameters - **licenseId** (str) - Required - The ID of the License to be retrieved. ### Response #### Success Response (200) - **License** (object) - A License object with the details of the requested License. ``` -------------------------------- ### Webhooks API Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List, create, get, update, and delete webhooks. ```APIDOC ## Webhooks API ### Description Endpoints for managing webhooks, including listing, creating, retrieving, updating, and deleting them. ### Method `webhooks.list()` `webhooks.create()` `webhooks.get()` `webhooks.update()` `webhooks.delete()` ### Endpoint `/webhooks` (Conceptual - actual endpoint depends on SDK implementation) ### Parameters #### Path Parameters None #### Query Parameters (for list) * **targetUrl** (str) - Optional - Filter webhooks by target URL. * **resource** (str) - Optional - Filter webhooks by resource type (e.g., 'messages', 'memberships'). * **event** (str) - Optional - Filter webhooks by event type (e.g., 'created', 'deleted'). #### Request Body (for create) * **name** (str) - Optional - A name for the webhook. * **targetUrl** (str) - Required - The URL where webhook events will be sent. * **resource** (str) - Required - The resource type to subscribe to (e.g., 'messages'). * **event** (str) - Required - The event type to subscribe to (e.g., 'created'). * **secret** (str) - Optional - A secret to use for HMAC signature validation. #### Request Body (for update) * **name** (str) - Optional - The updated name for the webhook. * **targetUrl** (str) - Optional - The updated target URL. * **secret** (str) - Optional - The updated secret. ### Request Example ```python # Assuming 'api' is an initialized WebexAPI object # List webhooks # all_webhooks = api.webhooks.list() # Create a new webhook # new_webhook = api.webhooks.create( # name='Message Handler', # targetUrl='https://your-app.com/webhook', # resource='messages', # event='created', # secret='YOUR_WEBHOOK_SECRET' # ) # Get a specific webhook # webhook_details = api.webhooks.get(webhookId='WEBHOOK_ID') # Update a webhook # updated_webhook = api.webhooks.update(webhookId='WEBHOOK_ID', name='Updated Message Handler') # Delete a webhook # api.webhooks.delete(webhookId='WEBHOOK_ID') ``` ### Response #### Success Response (200) * **id** (str) - The ID of the webhook. * **name** (str) - The name of the webhook. * **targetUrl** (str) - The target URL for webhook events. * **resource** (str) - The resource type. * **event** (str) - The event type. * **secret** (str) - The secret used for signing. * **created** (str) - The timestamp when the webhook was created. #### Response Example ```json { "id": "WEBHOOK_ID", "name": "Message Handler", "targetUrl": "https://your-app.com/webhook", "resource": "messages", "event": "created", "secret": "YOUR_WEBHOOK_SECRET", "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Initialize WebexAPI with Proxy Configuration Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/quickstart.rst.txt Initialize the WebexAPI object with proxy settings for environments behind a firewall. Refer to the requests library documentation for proxy details. ```python >>> from webexpythonsdk import WebexAPI >>> proxy = {'https': 'http://:'} >>> api = WebexAPI(access_token=, proxies=proxy) ``` -------------------------------- ### Run test suite Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/contributing.rst.txt Command to execute the project's test suite. ```bash # see below for more information on running the test suite locally make tests ``` -------------------------------- ### Teams API Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List, create, get, update, and delete teams. ```APIDOC ## Teams API ### Description Endpoints for managing teams, including listing, creating, retrieving, updating, and deleting them. ### Method `teams.list()` `teams.create()` `teams.get()` `teams.update()` `teams.delete()` ### Endpoint `/teams` (Conceptual - actual endpoint depends on SDK implementation) ### Parameters #### Path Parameters None #### Query Parameters (for list) * **orgId** (str) - Optional - Filter teams by organization ID. * **max** (int) - Optional - The maximum number of teams to return. #### Request Body (for create) * **name** (str) - Required - The name of the team. * **description** (str) - Optional - A description of the team. #### Request Body (for update) * **name** (str) - Optional - The updated name of the team. * **description** (str) - Optional - The updated description of the team. ### Request Example ```python # Assuming 'api' is an initialized WebexAPI object # List teams # all_teams = api.teams.list() # Create a new team # new_team = api.teams.create(name='Project Alpha Team', description='Team for Project Alpha') # Get a specific team # team_details = api.teams.get(teamId='TEAM_ID') # Update a team # updated_team = api.teams.update(teamId='TEAM_ID', name='Updated Project Alpha Team') # Delete a team # api.teams.delete(teamId='TEAM_ID') ``` ### Response #### Success Response (200) * **id** (str) - The ID of the team. * **name** (str) - The name of the team. * **description** (str) - The description of the team. * **orgId** (str) - The ID of the organization the team belongs to. * **created** (str) - The timestamp when the team was created. #### Response Example ```json { "id": "TEAM_ID", "name": "Project Alpha Team", "description": "Team for Project Alpha", "orgId": "ORG_ID", "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Initialize GuestIssuerAPI Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/guest_issuer.html Instantiates the API wrapper with a RestSession and object factory. ```python def __init__(self, session, object_factory): """Initialize a new GuestIssuerAPI object with the provided RestSession Args: session(RestSession): The RESTful session object to be used for API calls to the Webex service Raises: TypeError: If the parameter types are incorrect "" check_type(session, RestSession) super(GuestIssuerAPI, self).__init__() self._session = session self._object_factory = object_factory ``` -------------------------------- ### Memberships API Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html List, create, get, update, and delete memberships. ```APIDOC ## Memberships API ### Description Endpoints for managing memberships in rooms, including listing, creating, retrieving, updating, and deleting them. ### Method `memberships.list()` `members.create()` `memberships.get()` `memberships.update()` `memberships.delete()` ### Endpoint `/memberships` (Conceptual - actual endpoint depends on SDK implementation) ### Parameters #### Path Parameters None #### Query Parameters (for list) * **roomId** (str) - Optional - Filter memberships by room ID. * **personId** (str) - Optional - Filter memberships by person ID. * **personEmail** (str) - Optional - Filter memberships by person email. #### Request Body (for create) * **roomId** (str) - Required - The ID of the room. * **personId** (str) - Optional - The ID of the person to add. If not provided, the authenticated user is added. * **personEmail** (str) - Optional - The email of the person to add. Use either `personId` or `personEmail`. #### Request Body (for update) * **role** (str) - Optional - The new role for the membership (e.g., 'moderator'). ### Request Example ```python # Assuming 'api' is an initialized WebexAPI object # List memberships in a room # room_memberships = api.memberships.list(roomId='ROOM_ID') # Add a person to a room # new_membership = api.memberships.create( # roomId='ROOM_ID', # personEmail='user@example.com' # ) # Get a specific membership # membership_details = api.memberships.get(membershipId='MEMBERSHIP_ID') # Update a membership role # updated_membership = api.memberships.update(membershipId='MEMBERSHIP_ID', role='moderator') # Delete a membership # api.memberships.delete(membershipId='MEMBERSHIP_ID') ``` ### Response #### Success Response (200) * **id** (str) - The ID of the membership. * **roomId** (str) - The ID of the room. * **personId** (str) - The ID of the person. * **personEmail** (str) - The email of the person. * **isModerator** (bool) - Whether the person is a moderator. * **created** (str) - The timestamp when the membership was created. #### Response Example ```json { "id": "MEMBERSHIP_ID", "roomId": "ROOM_ID", "personId": "PERSON_ID", "personEmail": "user@example.com", "isModerator": false, "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Create ShowCard Action for Cards Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/index.html Example of defining a 'Show Card' action in an adaptive card, which reveals another card when clicked. ```python from webex_python_sdk.models.cards import ShowCard show_card_action = ShowCard(title="Show Details", card={"contentType": "application/vnd.microsoft.card.adaptive", "content": {"type": "AdaptiveCard", "body": [{"type": "TextBlock", "text": "Detailed information here."}]}}) ``` -------------------------------- ### GET /messages/{messageId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/messages.html Retrieves the details of a specific message by its ID. ```APIDOC ## GET /messages/{messageId} ### Description Retrieves the details of a message by its ID. ### Method GET ### Endpoint /messages/{messageId} ### Parameters #### Path Parameters - **messageId** (str) - Required - The ID of the message to be retrieved. ``` -------------------------------- ### Get Organization Details Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/organizations.html Retrieves details for a specific organization by its ID. ```python def get(self, orgId): """Get the details of an Organization, by ID. Args: orgId(str): The ID of the Organization to be retrieved. Returns: Organization: An Organization object with the details of the requested organization. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex cloud returns an error. """ check_type(orgId, str) # API request json_data = self._session.get(API_ENDPOINT + "/" + orgId) # Return a organization object created from the returned JSON object return self._object_factory(OBJECT_TYPE, json_data) ``` -------------------------------- ### Manage Rooms and Post Messages with Webex Python SDK Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/intro.rst.txt This comprehensive example showcases several Webex API operations using the SDK, including listing, deleting, and creating rooms, adding members, and posting messages with file attachments. It highlights the SDK's ability to handle multiple API calls efficiently and transparently manage pagination. ```python from webexpythonsdk import WebexAPI api = WebexAPI() # Find all rooms that have 'webexpythonsdk Demo' in their title all_rooms = api.rooms.list() demo_rooms = [room for room in all_rooms if 'webexpythonsdk Demo' in room.title] # Delete all of the demo rooms for room in demo_rooms: api.rooms.delete(room.id) # Create a new demo room demo_room = api.rooms.create('webexpythonsdk Demo') # Add people to the new demo room email_addresses = ["test01@cmlccie.com", "test02@cmlccie.com"] for email in email_addresses: api.memberships.create(demo_room.id, personEmail=email) # Post a message to the new room, and upload a file api.messages.create(demo_room.id, text="Welcome to the room!", files=["https://www.webex.com/content/dam/wbx/us/images/navigation/CiscoWebex-Logo_white.png"]) ``` -------------------------------- ### GET /people/me Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/people.html Retrieves the details of the person currently accessing the API. ```APIDOC ## GET /people/me ### Description Get the details of the person accessing the API. ### Method GET ### Endpoint /people/me ``` -------------------------------- ### Initialize WebexAPI with OAuth Source: https://webexcommunity.github.io/WebexPythonSDK/user/quickstart.html Authenticate using OAuth flow credentials by providing client and code information. ```python >>> from webexpythonsdk import WebexAPI >>> client_id = "" >>> client_secret = "" >>> oauth_code = "" >>> redirect_uri = "" >>> api = WebexAPI(client_id=client_id, client_secret=client_secret, oauth_code=oauth_code, redirect_uri=redirect_uri ) ``` -------------------------------- ### GET /people/{personId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/people.html Retrieves the details of a specific person by their ID. ```APIDOC ## GET /people/{personId} ### Description Retrieves the details of a specific person by their ID. ### Method GET ### Endpoint /people/{personId} ### Parameters #### Path Parameters - **personId** (str) - Required - The ID of the person. ``` -------------------------------- ### Configure test environment variables Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/contributing.rst.txt Example script for setting required environment variables before running the test suite. ```bash #!/usr/bin/env bash export WEBEX_ACCESS_TOKEN="" export WEBEX_TEST_DOMAIN="" export WEBEX_TEST_ID_START=42 export WEBEX_TEST_FILE_URL="https://www.webex.com/content/dam/wbx/us/images/navigation/CiscoWebex-Logo_white.png" ``` -------------------------------- ### GET /teams/{teamId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/teams.html Retrieves the details of a specific team by its ID. ```APIDOC ## GET /teams/{teamId} ### Description Returns a Team object with the details of the requested team. ### Method GET ### Endpoint /teams/{teamId} ### Parameters #### Path Parameters - **teamId** (str) - Required - The team ID. ### Response #### Success Response (200) - **Team** (object) - A Team object with the details of the requested team. ``` -------------------------------- ### Create WebexAPI Connection Object (Default Token) Source: https://webexcommunity.github.io/WebexPythonSDK/_sources/user/quickstart.rst.txt Initialize the WebexAPI object. By default, it attempts to use the WEBEX_ACCESS_TOKEN environment variable. An exception is raised if the token is not found. ```python from webexpythonsdk import WebexAPI api = WebexAPI() ``` ```python from webexpythonsdk import WebexAPI api = WebexAPI() Traceback (most recent call last): File "", line 1, in File "webexpythonsdk/__init__.py", line 114, in __init__ raise webexpythonsdkException(error_message) webexpythonsdkException: You must provide an Webex access token to interact with the Webex APIs, either via a WEBEX_ACCESS_TOKEN environment variable or via the access_token argument. ``` -------------------------------- ### GET /team/memberships/{membershipId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/team_memberships.html Retrieves details for a specific team membership. ```APIDOC ## GET /team/memberships/{membershipId} ### Description Get details for a team membership by its unique ID. ### Method GET ### Endpoint /team/memberships/{membershipId} ### Parameters #### Path Parameters - **membershipId** (str) - Required - The team membership ID. ``` -------------------------------- ### GET /webhooks/{webhookId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/webhooks.html Retrieves the details of a specific webhook by its ID. ```APIDOC ## GET /webhooks/{webhookId} ### Description Get the details of a webhook, by ID. ### Method GET ### Endpoint /webhooks/{webhookId} ### Parameters #### Path Parameters - **webhookId** (str) - Required - The ID of the webhook to be retrieved. ``` -------------------------------- ### GET /memberships/{membershipId} Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/memberships.html Retrieves the details of a specific membership by its ID. ```APIDOC ## GET /memberships/{membershipId} ### Description Get details for a membership, by ID. ### Method GET ### Endpoint /memberships/{membershipId} ### Parameters #### Path Parameters - **membershipId** (str) - Required - The membership ID. ### Response #### Success Response (200) - **Membership** (object) - A Membership object with the details of the requested membership. ``` -------------------------------- ### Initialize Multiple WebexAPI Objects Source: https://webexcommunity.github.io/WebexPythonSDK/user/quickstart.html Create distinct connection objects for different users by passing specific access tokens. ```python >>> from webexpythonsdk import WebexAPI >>> chris_at = 'lkj345w...' >>> veronica_at = 'kl45kln...' >>> chris_api = WebexAPI(access_token=chris_at) >>> veronica_api = WebexAPI(access_token=veronica_at) ``` -------------------------------- ### Get My Details Source: https://webexcommunity.github.io/WebexPythonSDK/user/api.html Retrieves the details of the currently authenticated user accessing the API. ```APIDOC ## GET /me ### Description Get the details of the person accessing the API. ### Method GET ### Endpoint /me ### Response #### Success Response (200) - **Person** (object) - A Person object with the details of the authenticated user. ### Error Handling - **ApiError**: If the Webex cloud returns an error. ``` -------------------------------- ### Get Organization Details Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/organizations.html Retrieves the details of a specific organization using its ID. ```APIDOC ## GET /organizations/{orgId} ### Description Gets the details of an Organization, by ID. ### Method GET ### Endpoint /organizations/{orgId} ### Path Parameters - **orgId** (str) - Required - The ID of the Organization to be retrieved. ### Response #### Success Response (200) - **organization** (Organization) - An Organization object with the details of the requested organization. ### Response Example ```json { "id": "string", "name": "string", "created": "string" } ``` ``` -------------------------------- ### WebexAPI Initialization and Authentication Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api.html This section details how to initialize the WebexAPI object and authenticate using OAuth. ```APIDOC ## WebexAPI Class ### Description Provides a client for accessing the Webex API. ### Method `__init__` ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from webexteamssdk import WebexAPI # Initialize with an access token api = WebexAPI(access_token='YOUR_ACCESS_TOKEN') ``` ### Response #### Success Response (200) N/A #### Response Example N/A --- ## Create WebexAPI from OAuth Code ### Description Create a new WebexAPI connection object using an OAuth code. This method exchanges an Authorization Code for an Access Token, then uses the access token to create a new WebexAPI connection object. ### Method `from_oauth_code` (classmethod) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments * **client_id** (str) - Provided when you created your integration. * **client_secret** (str) - Provided when you created your integration. * **code** (str) - The Authorization Code provided by the user OAuth process. * **redirect_uri** (str) - The redirect URI used in the user OAuth process. ### Returns * **WebexAPI**: A new WebexAPI object initialized with the access token from the OAuth Authentication Code exchange. ### Raises * **TypeError**: If the parameter types are incorrect. * **ApiError**: If the Webex cloud returns an error. ### Request Example ```python from webexteamssdk import WebexAPI api = WebexAPI.from_oauth_code( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', code='AUTHORIZATION_CODE', redirect_uri='YOUR_REDIRECT_URI' ) ``` --- ## Create WebexAPI from OAuth Refresh Token ### Description Create a new WebexAPI connection object using an OAuth refresh token. This method exchanges a refresh token for an Access Token, then uses the access token to create a new WebexAPI connection object. ### Method `from_oauth_refresh` (classmethod) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments * **client_id** (str) - Provided when you created your integration. * **client_secret** (str) - Provided when you created your integration. * **refresh_token** (str) - Provided when you requested the Access Token. ### Returns * **WebexAPI**: A new WebexAPI object initialized with the access token from the OAuth Refresh Token exchange. ### Raises * **TypeError**: If the parameter types are incorrect. * **ApiError**: If the Webex cloud returns an error. ### Request Example ```python from webexteamssdk import WebexAPI api = WebexAPI.from_oauth_refresh( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', refresh_token='YOUR_REFRESH_TOKEN' ) ``` ``` -------------------------------- ### Create Submit Action Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/admin_audit_events.html Example of creating a submit action for a Webex card, which sends data back to the application. ```python from webexpythonsdk.cards import Submit submit_action = Submit(title='Submit', data={'action': 'submitForm'}) ``` -------------------------------- ### Get person details Source: https://webexcommunity.github.io/WebexPythonSDK/_modules/webexpythonsdk/api/people.html Retrieves details for a specific person by their unique ID. ```python def get(self, personId): """Get a person's details, by ID. Args: personId(str): The ID of the person to be retrieved. Returns: Person: A Person object with the details of the requested person. Raises: TypeError: If the parameter types are incorrect. ```