biz.neustar.pagerduty
Class PagerDutyClient

java.lang.Object
  extended by biz.neustar.pagerduty.PagerDutyClient

public class PagerDutyClient
extends Object


Constructor Summary
PagerDutyClient(String subdomain, String username, String password)
           
 
Method Summary
 EventResponse acknowledge(String serviceKey, String description, String incidentKey, Object details)
          Acknowledges an existing event in PagerDuty for the supplied service and incident key, including an optional description and details to go along with the message.
 List<Incident> getIncidents(Date start, Date end, IncidentsQuery query)
          Returns the incidents based on the supplied date range and query parameters.
 int getIncidentsCount(Date start, Date end, IncidentsQuery query)
          Returns the count of incidents based on the supplied date range and query parameters.
 EventResponse resolve(String serviceKey, String description, String incidentKey, Object details)
          Resolves an existing event in PagerDuty for the supplied service and incident key, including an optional description and details to go along with the message.
 EventResponse trigger(String serviceKey, String description, String incidentKey, Object details)
          Triggers a new incident in PagerDuty for the supplied service, including an optional description, incident key, and details to go along with the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagerDutyClient

@Inject
public PagerDutyClient(@Named(value="pagerduty.subdomain")
                              String subdomain,
                              @Named(value="pagerduty.username")
                              String username,
                              @Named(value="pagerduty.password")
                              String password)
Method Detail

getIncidentsCount

public int getIncidentsCount(Date start,
                             Date end,
                             IncidentsQuery query)
                      throws IOException,
                             QueryException,
                             InternalException
Returns the count of incidents based on the supplied date range and query parameters.

Parameters:
start - the start of the query range
end - the end of the query range
query - the query details, such as new IncidentsQuery().sortBy(RESOLVED_ON, ASC).withStatus("resolved")
Returns:
the count of incidents
Throws:
IOException - when there is an IO problem such as making a network request
QueryException - when PagerDuty rejects the query being made and responds with an error and reason
InternalException - when PagerDuty returns a 5xx error code

getIncidents

public List<Incident> getIncidents(Date start,
                                   Date end,
                                   IncidentsQuery query)
                            throws IOException,
                                   QueryException,
                                   InternalException
Returns the incidents based on the supplied date range and query parameters.

Parameters:
start - the start of the query range
end - the end of the query range
query - the query details, such as new IncidentsQuery().sortBy(RESOLVED_ON, ASC).withStatus("resolved")
Returns:
the count of incidents
Throws:
IOException - when there is an IO problem such as making a network request
QueryException - when PagerDuty rejects the query being made and responds with an error and reason
InternalException - when PagerDuty returns a 5xx error code

trigger

public EventResponse trigger(String serviceKey,
                             String description,
                             String incidentKey,
                             Object details)
                      throws IOException,
                             InternalException,
                             InvalidEventException
Triggers a new incident in PagerDuty for the supplied service, including an optional description, incident key, and details to go along with the message.

Parameters:
serviceKey - the service key to for the incident
description - an optional description for the incident
incidentKey - an optional key (if not supplied, PagerDuty will generate one and return it)
details - an object that will be converted to a JSON structure and included with the incident details (can be Map, real object, etc)
Returns:
the event response details
Throws:
IOException - when there is an IO problem such as making a network request
InternalException - when a 5xx response code is returned
InvalidEventException - when a 400 response code is returned, indicating that the event supplied is invalid

acknowledge

public EventResponse acknowledge(String serviceKey,
                                 String description,
                                 String incidentKey,
                                 Object details)
                          throws IOException,
                                 InternalException,
                                 InvalidEventException
Acknowledges an existing event in PagerDuty for the supplied service and incident key, including an optional description and details to go along with the message.

Parameters:
serviceKey - the service key to for the incident
description - an optional description for the incident
incidentKey - a required incident key that maps to the incident you wish to acknowledge
details - an object that will be converted to a JSON structure and included with the incident details (can be Map, real object, etc)
Returns:
the event response details
Throws:
IOException - when there is an IO problem such as making a network request
InternalException - when a 5xx response code is returned
InvalidEventException - when a 400 response code is returned, indicating that the event supplied is invalid

resolve

public EventResponse resolve(String serviceKey,
                             String description,
                             String incidentKey,
                             Object details)
                      throws IOException,
                             InternalException,
                             InvalidEventException
Resolves an existing event in PagerDuty for the supplied service and incident key, including an optional description and details to go along with the message.

Parameters:
serviceKey - the service key to for the incident
description - an optional description for the incident
incidentKey - a required incident key that maps to the incident you wish to acknowledge
details - an object that will be converted to a JSON structure and included with the incident details (can be Map, real object, etc)
Returns:
the event response details
Throws:
IOException - when there is an IO problem such as making a network request
InternalException - when a 5xx response code is returned
InvalidEventException - when a 400 response code is returned, indicating that the event supplied is invalid


Copyright © 2011. All Rights Reserved.