Skip to main content

License: MIT Webex Events

Webex EVENTS

Webex Events Api Python SDK

Webex Events provides a range of additional SDKs to accelerate your development process. They allow a standardized way for developers to interact with and leverage the features and functionalities. Pre-built code modules will help access the APIs with your private keys, simplifying data gathering and update flows.

Requirements

  • Python 3.9+

Installation

Via command line:

pip install webex-events

In your python script:

from webexevents.client import query

Configuration

from webexevents.configuration import Configuration

Configuration.set_access_token('access_token') # required
Configuration.set_read_timeout_sec(40.0) # optional, default 60.0
Configuration.set_connect_timeout_sec(30.0) # optional, default 30.0
Configuration.set_max_retries(5) # optional, default 3
Configuration.set_logger_stream(level=logging.DEBUG) # default logging is disabled

Usage

from webexevents.client import query

query_str = """
    query EventsConnection($first: Int) {
        eventsConnection(first: $first){
            edges{
                cursor
                node{
                    id
                    name
                    groups{
                        id
                        name
                    }
                }
            }
        }
    }
  """
response = query(query_str, 'EventsConnection', {'first': 20})
event = response.content["data"]["eventsConnection"]["edges"][0]

If the request is successful, Client.query will return Response object which has the following properties.

Method Type
status_code int
response_headers dict
content dict
request_headers dict
request_body str
url str
retry_count int
time_spent_in_ms int
rate_limiter RateLimiter

For non 200 status codes, an exception is raised for every status code such as webexevents.exceptions.ServerError for server errors. For the flow-control these exceptions should be handled like the following. This is an example for 429 status code. For the full list please refer to this file.

from webexevents.client import query
from webexevents.exceptions import *
import time

query_str = 'your query here'

try:
    response = query(query_str, 'EventsConnection', {'first': 20})
except DailyQuotaIsReachedError as ex:
    pass
    # Do something here
except SecondBasedQuotaIsReachedError as e:
    sleep_time = e.response.rate_limiter.second_based_cost_threshold
    time.sleep(sleep_time)
    # retry

By default, webexevents.client.query is retryable under the hood. It retries the request several times for the following exceptions.

webexevents.exceptions.RequestTimeoutError => 408
webexevents.exceptions.ConflictError => 409
webexevents.exceptions.SecondBasedQuotaIsReachedError => 429
webexevents.exceptions.BadGatewayError => 502
webexevents.exceptions.ServiceUnavailableError => 503
webexevents.exceptions.GatewayTimeoutError => 504

For Introspection

Client.do_introspection_query

Idempotency

The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. When doing a mutation request, use an idempotency key. If a connection error occurs, you can repeat the request without risk of creating a second object or performing the update twice.

To perform mutation request, you must add a header which contains the idempotency key such as Idempotency-Key: <your key>. The SDK does not produce an Idempotency Key on behalf of you if it is missed. Here is an example like the following:

from webexevents.client import query
from webexevents.exceptions import *
import time

mutation_str = """
          mutation TrackDelete($input: TrackDeleteInput!) {
            trackDelete(input: $input) {
              success
            }
          }
"""

try:
    response = query(mutation_str, "trackDelete", {"id": 10}, options={"idempotency_key": "unique_key"})

except ConflictError as e:  # Conflict errors are retriable, but to guarantee it you can handle the exception again.
    time.sleep(0.2)
    # retry

Telemetry Data Collection

Webex Events collects telemetry data, including hostname, operating system, language and SDK version, via API requests. This information allows us to improve our services and track any usage-related faults/issues. We handle all data with the utmost respect for your privacy. For more details, please refer to the Privacy Policy at https://www.cisco.com/c/en/us/about/legal/privacy-full.html

Development

After checking out the repo and then install pip-tools if it has not been installed already.

python -m pip install pip-tools

compile project

 pip-compile pyproject.toml

and install dependencies:

pip-sync

then, you need to install dev dependencies

pip install '.[dev]'

to run the tests

pytest 

build and upload to test env:

python -m pip install build twine
python -m build
twine check dist/*
cat ~/.pypirc #check api key is here
twine upload -r testpypi dist/*

install package to local as editable package python -m pip install -e .

Contributing

Please see the contributing guidelines.

License

The package is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Webex Events API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Metadata

Release files for webex-events 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webex-events 1.0.0
File Size Uploaded
webex_events-1.0.0.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for webex-events 1.0.0
File Interpreter ABI Platform
webex_events-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.6 kB

Release files / webex_events-1.0.0.tar.gz

Download URL webex_events-1.0.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
844235e84df319829c0143c81e034fed53701417338fb0bdecaa353dad4c6124
BLAKE2b-256 checksum
How to use checksums
2a3fe121a2234830d1be14aca74d2447ccf5eb9caa45fbcd9ffa9a9ca8d0e54c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / webex_events-1.0.0-py3-none-any.whl

Download URL webex_events-1.0.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
896be96f3eda2646ef5b65633f43455f386f167d7e504b5837df379762b69520
BLAKE2b-256 checksum
How to use checksums
0679af997ca85aa1f9362ec2c635f37799d2a8c97b2723d922f58cb91decb9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page