Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Edit the IPs that should be monitored by the alert.
:param aid: Alert ID
:type name: str
:param ip: Network range(s) to monitor
:type ip: str OR list of str
:returns: A dict describing the alert
"""
data = {
'filters': {
'ip': ip,
},
}
response = api_request(self.api_key, '/shodan/alert/{}'.format(aid), data=data, params={}, method='post',
proxies=self._session.proxies)
return response
def alerts(self, aid=None, include_expired=True):
"""List all of the active alerts that the user created."""
if aid:
func = '/shodan/alert/%s/info' % aid
else:
func = '/shodan/alert/info'
response = api_request(self.api_key, func, params={
'include_expired': include_expired,
}, proxies=self._session.proxies)
return response
def delete_alert(self, aid):
"""Delete the alert with the given ID."""
func = '/shodan/alert/%s' % aid
response = api_request(self.api_key, func, params={}, method='delete',
proxies=self._session.proxies)
return response
:param name: Name of the alert
:type name: str
:param ip: Network range(s) to monitor
:type ip: str OR list of str
:returns: A dict describing the alert
"""
data = {
'name': name,
'filters': {
'ip': ip,
},
'expires': expires,
}
response = api_request(self.api_key, '/shodan/alert', data=data, params={}, method='post',
proxies=self._session.proxies)
return response