Skip to main content

Webex Events SDK

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webex_events-1.0.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webex_events-1.0.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file webex_events-1.0.0.tar.gz.

File metadata

  • Download URL: webex_events-1.0.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for webex_events-1.0.0.tar.gz
Algorithm Hash digest
SHA256 844235e84df319829c0143c81e034fed53701417338fb0bdecaa353dad4c6124
MD5 c32066efbbbaa68c676f76de525b4a04
BLAKE2b-256 2a3fe121a2234830d1be14aca74d2447ccf5eb9caa45fbcd9ffa9a9ca8d0e54c

See more details on using hashes here.

File details

Details for the file webex_events-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: webex_events-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for webex_events-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 896be96f3eda2646ef5b65633f43455f386f167d7e504b5837df379762b69520
MD5 cebcc254d043c4338541456dc7dd5c59
BLAKE2b-256 0679af997ca85aa1f9362ec2c635f37799d2a8c97b2723d922f58cb91decb9cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page