salesforce / python-argusclient Goto Github PK
View Code? Open in Web Editor NEWA minimal client library for Argus webservice
License: BSD 3-Clause "New" or "Revised" License
A minimal client library for Argus webservice
License: BSD 3-Clause "New" or "Revised" License
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/pkuznetsov/sfstore/moncfg/moncfg/__main__.py", line 87, in <module>
main()
File "/Users/pkuznetsov/sfstore/moncfg/moncfg/__main__.py", line 65, in main
services[service].push(config)
File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 124, in push
self._delete_notification(argus_alert, argus_notification)
File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 205, in _delete_notification
self._call_argus(alert.notifications.delete, notification.argus_id)
File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 260, in _call_argus
return argus(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/argusclient-0.2dev_r0-py2.7.egg/argusclient/client.py", line 550, in delete
AttributeError: 'tuple' object has no attribute 'argus_id'
Currently, most of the code is written such that it works only with a single notification or trigger. When there are multiple notifications or triggers, the interface is buggy as alert.notifications
and alert.trigger
code gets set to a service object instead of a list
and so the client code can't even access them.
@mock.patch('requests.Session.put', return_value=MockResponse(json.dumps(alert_D), 200))
def testUpdateAlert(self, mockPut):
res = self.argus.alerts.update(testId, Alert.from_dict(alert_D))
self.assertTrue(isinstance(self.argus.alerts.get(testId), Alert))
self.assertEquals(self.argus.alerts.get(testId).to_dict(), alert_D)
self.assertIn((os.path.join(endpoint, "alerts", str(testId)),), tuple(mockPut.call_args))
// The following fails:
for method in ['get', 'add', 'update', 'delete']:
self.assertTrue(hasattr(res.triggers, method), msg='no alert.triggers.{}()'.format(method))
self.assertTrue(hasattr(res.notifications, method), msg='no alert.notifications.{}()'.format(method))
I faced this in the alert object but I suspect it occurs across all objects.
Issue: Per documentation, the check to see if alert exists only works if the alert exists.
If it doesn't, it throws httplib.NOT_FOUND(404) exception from here. Traceback below.
All actions including Alert creation/modification should be idempotent. So DELETE and PUT is the way to go. We just need a better mechanism for handling the error.
May be instead of raise
, just catch the exception and gently let the calling function know? Thoughts?
Exception:
Traceback (most recent call last):
File "alert.py", line 32, in <module>
alertobj = argus.alerts.get_user_alert(user, alert_name, shared=False)
File "client.py", line 473, in get_user_alert
alerts = self.argus._request("get", "alerts/meta", params=dict(alertname=alertName, ownername=ownerName, shared=shared))
File "client.py", line 555, in with_retry
return f(*args, **kwargs)
File "client.py", line 588, in with_auth_token
return f(*args, **kwargs)
File "client.py", line 708, in _request
return self._request_no_auth(method, path, params, dataObj, encCls, decCls)
File "client.py", line 730, in _request_no_auth
res = check_success(resp, decCls)
File "client.py", line 744, in check_success
raise ArgusException("Object not found at endpoint: %s message: %s" % (resp.request.url, resp.text))
argusclient.client.ArgusException: Object not found at endpoint:
https://<argus_url>/argusws/alerts/meta?shared=False&ownername=<owner_name>&alertname=<alert_name>
message: {"status":404,"message":"Not Found"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.