Package: cachet-client
cachet-clientA python 3.6+ API client for the open source status page systemCachet.cachet-client on githubcachet-client on PyPIcachet-client documentationThe goal of this package is to create a user friendly interface
to the Cachet API.Resources are returned as objects clearly separating read only
properties from the ones we can change. The raw json response
is always available in anattrspropertyActive use of type hints throughout the entire codebase
making code completion a breezeProper pagination under the hood. Method listing resources
will return generators. You can configure the start page and
page size that fits the situation. Each new page leads to
a new http request.Client is using a single session regardless of resource type
making more complex work a lot faster (connection reuse)A very extensive set of tests/unit tests.Easy to extend and testDocumentationPlease don't hesitate opening an issue about anything related to this package.Installpip install cachet-clientExampleimportcachetclientfromcachetclient.v1importenumsclient=cachetclient.Client(endpoint='https://status.test/api/v1',api_token='secrettoken',)Check if api is respondingifclient.ping():print("Cachet is up and running!")Create and delete a subscribersub=client.subscribers.create(email='user@example.test',verify=True)sub.delete()List all subscribers paginated (generator). Each new page is fetched
from the server under the hood.forsubinclient.subscribers.list(page=1,per_page=100):print(sub.id,sub.email)Create a component issueissue=client.incidents.create(name="Something blew up!",message="We are looking into it",status=enums.INCIDENT_INVESTIGATING,# Optional for component issuescomponent_id=mycomponent.id,component_status=enums.COMPONENT_STATUS_MAJOR_OUTAGE,).. and most other features supported by the Cachet APILocal DevelopmentLocal setup:python-mvirtualenv.venv
..venv/bin/activate
pipinstall-e.TestsThis project has a fairly extensive test setup.Unit tests are located intests/including a fake
implementation of the Cachet API.A simpler test script underextras/live_run.pythat
needs a running test instance of Cachet.Running unit testspipinstall-rtests/requirements.txt
tox# Optionallytox-epep8# for pep8 run onlytox-epy36# tests only# Running tests with pytest also works, but this works poorly in combination with environment variables for the live test script (tox separates environments)pytesttests/Testing with real Cachet serviceDo not run this script against a system in production.
This is only for a test service.
Cachet can easily be set up locally with docker:https://github.com/CachetHQ/DockerOptionally we can run cachet from source:https://github.com/CachetHQ/DockerA local setup is also located in the root or the repo (docker-compose.yaml).You need to set the following environment variables.CACHET_ENDPOINT
CACHET_API_TOKENRunning tests:pythonextras/live_run.py
...=================================================Numberoftests:10Successful:10Failure:0Percentagepassed:100.0%=================================================Building Docspipinstall-rdocs/requirements.txt
pythonsetup.pybuild_sphinxContributingDo not hesitate opening issues or submit completed
or partial pull requests. Contributors of all
experience levels are welcome.This project is sponsored byzetta.io