Code Documentation¶
Alert¶
-
class
pagerduty_api.
Alert
(service_key, *args, **kwargs)¶ An interface for interacting with PagerDuty alerts.
Instantiate with a service API key (A unique id for the service you want to trigger an alert for)
-
__init__
(service_key, *args, **kwargs)¶ Parameters: service_key (str) – Service API Key is a unique ID generated in PagerDuty for a Generic API Service
-
trigger
(description, incident_key=None, client=None, client_url=None, details=None)¶ Triggers a PagerDuty Alert. See the PagerDuty API trigger docs for more details.
Parameters: - description (str) – A Description of the alert. 1024 character max
- incident_key (str) – A unique ID to de-duplicate incident reports. If no key is present, an MD5 hash of the description is used.
- client (str) – The name of the monitoring client that is triggering this event. Optional
- client_url (str) – The URL of the monitoring client that is triggering this event. Optional
- details (dict) – An arbitrary JSON object containing any data you’d like included in the incident log. Optional
Return type: Returns: The JSON response of the API
{ "status": "success", "message": "Event processed", "incident_key": "srv01/HTTP" }
-
acknowledge
(incident_key=None, description=None, details=None)¶ Acknowledges a PagerDuty Alert. See the PagerDuty API ack docs for more details.
Parameters: - incident_key (str) – The key for the incident to acknowledge. If None, it will use the incident key assigned when you triggered the alert.
- description (str) – Text that will appear in the incident’s log associated with this event. Optional
- details (dict) – An arbitrary JSON object containing any data you’d like included in the incident log. Optional
Raises: An
IncidentKeyException
if the Alert doesn’t have an incident key and one is not passed to the methodReturn type: Returns: The JSON response of the API
{ "status": "success", "message": "Event processed", "incident_key": "srv01/HTTP" }
-
resolve
(incident_key=None, description=None, details=None)¶ Resolves a PagerDuty Alert. See the PagerDuty API resolve docs for more details.
Parameters: - incident_key (str) – The key for the incident to resolve. If None, it will use the incident key assigned when you triggered the alert.
- description (str) – Text that will appear in the incident’s log associated with this event. Optional
- details (dict) – An arbitrary JSON object containing any data you’d like included in the incident log. Optional
Raises: An
IncidentKeyException
if the Alert doesn’t have an incident key and one is not passed to the methodReturn type: Returns: The JSON response of the API
{ "status": "success", "message": "Event processed", "incident_key": "srv01/HTTP" }
-