Usage¶
import statuspageio
# Then we instantiate a client (as shown below)
Build a client¶
Using this api without authentication gives an error
client = statuspageio.Client(api_key='<YOUR_PERSONAL_API_KEY>', page_id=<YOUR_PERSONAL_PAGE_ID')
or with User management enabled
client = statuspageio.Client(api_key='<YOUR_PERSONAL_API_KEY>',
page_id=<YOUR_PERSONAL_PAGE_ID',organization_id=<YOUR_PERSONAL_ORGANIZATION_ID)
Note
The organization_id can be found by login in to https://manage.statuspage.io/ and clicking team members. It’s part of the url https://manage.statuspage.io/organizations/REMOVED/team
Client Options¶
The following options are available while instantiating a client:
- api_key: Personal API Key
- page_id: Personal page id
- organization_id: Personal organization id, used for managing users.
- base_url: Base url for the api
- user_agent: Default user-agent for all requests
- timeout: Request timeout
- verbose: Verbose/debug mode
Architecture¶
The library follows few architectural principles you should understand before digging deeper. 1. Interactions with resources are done via service objects. 2. Service objects are exposed as properties on client instances. 3. Service objects expose resource-oriented actions. 4. Actions return dictionaries that support attribute-style access, a la JavaScript (thanks to Bunch and it’s form Munch).
For example, to interact with components API you will use
statuspageio.ComponentsService, which you can get if you call:
client = statuspageio.Client(api_key='<YOUR_PERSONAL_API_KEY>', page_id=<YOUR_PERSONAL_PAGE_ID')
client.components # statuspageio.ComponentsService
To retrieve list of resources and use filtering you will call #list
method:
client = statuspageio.Client(api_key='<YOUR_PERSONAL_API_KEY>', page_id=<YOUR_PERSONAL_PAGE_ID')
client.components.list() # list(dict|Munch)
Resources and actions¶
Documentation for every action can be found in statuspageio/services.py
file or in the following statuspageio package
In short we have implimented the folowing API functions at this time.
Page¶
Actions:
- Retrieve the page information -
client.page.get - Update the page information -
client.page.update
Components¶
Actions:
- List all components -
client.components.list - Create a component -
client.components.create - Update a component -
client.components.update - Delete a component -
client.components.delete
Incidents¶
- List all incidents -
client.incidents.list - List unresolved incidents -
client.incidents.list_unresolved - List scheduled incidents -
client.incidents.list_scheduled - Create a incident -
client.incidents.create - Update a incident -
client.incidents.update - Delete a incident -
client.incidents.delete
Subscribers¶
- List all subscribers -
client.subscribers.list - Create a subscribers -
client.subscribers.create - Delete a subscribers -
client.subscribers.delete
Metrics¶
- List all available providers -
client.metrics.list_available - List linked providers -
client.metrics.list_linked - List metrics for provider -
client.metrics.list_metrics_for_provider - Create a custom metric -
client.metrics.create - Delete a custom metric -
client.metrics.delete - Submit data for a custom metric -
client.metrics.submit_data
Users¶
- List all Users -
client.users.list - Create a User -
client.users.create - Delete a User -
client.users.delete