Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Library Usage
Set up a Pingdom connection:

>>> import pingdom
>>> c = pingdom.PingdomConnection(PINGDOM_USERNAME, PINGDOM_PASSWORD, API_KEY) # Same credentials you use for the Pingdom website
>>> c = pingdom.PingdomConnection(PINGDOM_USERNAME, PINGDOM_PASSWORD, API_KEY) # Same credentials you use for the Pingdom website. (email=EMAIL is required for multi users accounts)

Create a new Pingdom check:

Expand Down
11 changes: 8 additions & 3 deletions pingdom/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def __init__(self, connection, resource, post_data=None, method=None,

:type connection: :class:`PingdomConnection`
:param connection: Pingdom connection object populated with a username,
password and base URL
password and base URL.
Additional email can be provided for multi user authentication:
https://www.pingdom.com/resources/api#multi-user+authentication

:type resource: string
:param resource: Pingdom resource to query (in all lowercase)
Expand All @@ -60,6 +62,8 @@ def __init__(self, connection, resource, post_data=None, method=None,
self.method = self._method(method, post_data)
self.auth = HTTPBasicAuth(connection.username, connection.password)
self.headers = {'App-Key': connection.apikey}
if connection.email:
self.headers['Account-Email'] = connection.email

# TODO ensure this still works
# # Enable gzip
Expand Down Expand Up @@ -98,13 +102,14 @@ def __repr__(self):

class PingdomConnection(object):
def __init__(self, username, password, apikey='',
base_url=BASE_URL + BASE_VERSION):
base_url=BASE_URL + BASE_VERSION, email=''):
"""Interface to the Pingdom API."""

self.username = username
self.password = password
self.apikey = apikey
self.base_url = base_url
self.email = email

def __repr__(self):
return "Connection:%s" % self.base_url
Expand Down Expand Up @@ -198,7 +203,7 @@ def get_summary_average(self, check_id, from_time=0, to_time=0,
(check_id, from_time, to_time, include_uptime)
response = PingdomRequest(self, rs).fetch()
return response.content['summary']

def get_actions(self, limit):
"""Get a list of Pingdom actions/alerts"""
response = PingdomRequest(self, 'actions/?limit=%s' % limit).fetch()
Expand Down