Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from datadog import initialize, api
options = {
'api_key': '9775a026f1ca7d1c6c5af9d94d9595a4',
'app_key': '87ce4a24b5553d2e482ea8a8500e71b8ad4554ff'
}
initialize(**options)
# Get a monitor's details
api.Monitor.get(2081, group_states='all')
from datadog import initialize, api
options = {
'api_key': '9775a026f1ca7d1c6c5af9d94d9595a4',
'app_key': '87ce4a24b5553d2e482ea8a8500e71b8ad4554ff'
}
initialize(**options)
# Unmute all alerts
api.Monitor.unmute(2088)
from datadog import initialize, api
options = {
'api_key': '',
'app_key': ''
}
initialize(**options)
# Check if you can delete the given monitors.
api.Monitor.can_delete(monitor_ids=[56838, 771060, 1000376])
def _run(self, **kwargs):
return api.Monitor.mute(kwargs.pop("monitor_id"), **kwargs)
def _run(self, **kwargs):
return api.Monitor.get(kwargs.pop("monitor_id"), **kwargs)
def _get_monitor(module):
if module.params['id'] is not None:
monitor = api.Monitor.get(module.params['id'])
if 'errors' in monitor:
module.fail_json(msg="Failed to retrieve monitor with id %s, errors are %s" % (module.params['id'], str(monitor['errors'])))
return monitor
else:
monitors = api.Monitor.get_all()
for monitor in monitors:
if monitor['name'] == _fix_template_vars(module.params['name']):
return monitor
return {}
from datadog import initialize, api
options = {
'api_key': '',
'app_key': ''
}
initialize(**options)
# Mute all monitors
api.Monitor.mute_all()
def delete_monitor(module):
monitor = _get_monitor(module)
if not monitor:
module.exit_json(changed=False)
try:
msg = api.Monitor.delete(monitor['id'])
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))