From 125f47b794e125bc8555dafddf9f8286ad479076 Mon Sep 17 00:00:00 2001 From: xino Date: Wed, 12 Jul 2017 10:32:46 +0200 Subject: [PATCH 1/2] add include_tags parameter + add tags to PingdomCheck object --- pingdomlib/check.py | 17 +++++++++++++---- pingdomlib/pingdom.py | 3 +-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pingdomlib/check.py b/pingdomlib/check.py index ccd25ac..2eaf7dd 100644 --- a/pingdomlib/check.py +++ b/pingdomlib/check.py @@ -1,6 +1,6 @@ import sys from pingdomlib.analysis import PingdomAnalysis - +import json checktypes = ['http', 'httpcustom', 'tcp', 'ping', 'dns', 'udp', 'smtp', 'pop3', 'imap'] @@ -47,7 +47,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 @@ -73,7 +73,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: @@ -172,6 +172,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""" @@ -234,6 +239,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: @@ -366,7 +375,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' + '.modify()\n') diff --git a/pingdomlib/pingdom.py b/pingdomlib/pingdom.py index 7279c62..0688489 100644 --- a/pingdomlib/pingdom.py +++ b/pingdomlib/pingdom.py @@ -1,6 +1,5 @@ import requests import sys - from pingdomlib.check import PingdomCheck from pingdomlib.contact import PingdomContact from pingdomlib.reports import PingdomEmailReport, PingdomSharedReport @@ -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) From 8e42711e471ce4d06c018b8e566910ab757af3a4 Mon Sep 17 00:00:00 2001 From: xino Date: Wed, 12 Jul 2017 10:36:17 +0200 Subject: [PATCH 2/2] delete unnecessary import --- pingdomlib/check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pingdomlib/check.py b/pingdomlib/check.py index 2eaf7dd..788041a 100644 --- a/pingdomlib/check.py +++ b/pingdomlib/check.py @@ -1,6 +1,5 @@ import sys from pingdomlib.analysis import PingdomAnalysis -import json checktypes = ['http', 'httpcustom', 'tcp', 'ping', 'dns', 'udp', 'smtp', 'pop3', 'imap']