Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include_tags parameter + tags attributes in PingdomCheck #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
16 changes: 12 additions & 4 deletions pingdomlib/check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from pingdomlib.analysis import PingdomAnalysis


checktypes = ['http', 'httpcustom', 'tcp', 'ping', 'dns', 'udp', 'smtp',
'pop3', 'imap']

Expand Down Expand Up @@ -47,7 +46,7 @@ class PingdomCheck(object):
'sendnotificationwhendown', 'notifyagainevery',
'notifywhenbackup', 'created', 'type', 'hostname',
'status', 'lasterrortime', 'lasttesttime',
'use_legacy_notifications', 'lastresponsetime', 'probe_filters',]
'use_legacy_notifications', 'lastresponsetime', 'probe_filters','tags',]

def __init__(self, instantiator, checkinfo=dict()):
self.pingdom = instantiator
Expand All @@ -73,7 +72,7 @@ def __setattr__(self, key, value):
'postdata', 'additionalurls', 'stringtosend',
'stringtoexpect', 'expectedip', 'nameserver',
'use_legacy_notifications', 'host', 'alert_policy',
'autoresolve', 'probe_filters']:
'autoresolve', 'probe_filters','tags']:
if self.pingdom.pushChanges:
self.modify(**{key: value})
else:
Expand Down Expand Up @@ -172,6 +171,11 @@ def __addDetails__(self, checkinfo):
else:
object.__setattr__(self, 'paused', False)

if 'tags' in checkinfo:
object.__setattr__(self, 'tags', checkinfo['tags'])
else:
object.__setattr__(self, 'tags', None)

def getDetails(self):
"""Update check details, returns dictionary of details"""

Expand Down Expand Up @@ -234,6 +238,10 @@ def modify(self, **kwargs):

* probe_filters -- Can be one of region: NA, region: EU, region: APAC
Type: String

* tags -- Tags for this check
Type: String ['high', 'critical', 'db']


HTTP check options:

Expand Down Expand Up @@ -366,7 +374,7 @@ def modify(self, **kwargs):
'shouldnotcontain', 'postdata', 'additionalurls',
'stringtosend', 'stringtoexpect', 'expectedip',
'nameserver', 'use_legacy_notifications', 'host',
'alert_policy', 'autoresolve', 'probe_filters']:
'alert_policy', 'autoresolve', 'probe_filters','tags']:
sys.stderr.write("'%s'" % key + ' is not a valid argument of' +
'<PingdomCheck>.modify()\n')

Expand Down
3 changes: 1 addition & 2 deletions pingdomlib/pingdom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requests
import sys

from pingdomlib.check import PingdomCheck
from pingdomlib.contact import PingdomContact
from pingdomlib.reports import PingdomEmailReport, PingdomSharedReport
Expand Down Expand Up @@ -210,7 +209,7 @@ def getChecks(self, **parameters):

# Warn user about unhandled parameters
for key in parameters:
if key not in ['limit', 'offset', 'tags']:
if key not in ['limit', 'offset', 'tags', 'include_tags']:
sys.stderr.write('%s not a valid argument for getChecks()\n'
% key)

Expand Down