Module: PagerDuty::Client::Notifications

Included in:
PagerDuty::Client
Defined in:
lib/pager_duty/client/notifications.rb

Overview

When an incident is triggered or escalated, it creates a notification.

Notifications are messages containing the details of the incident, and can be sent through SMS, email, phone calls, and push notifications.

Notifications cannot be created directly through the API; they are a result of other actions.

The API provides read-only access to the notifications generated by PagerDuty.

Instance Method Summary collapse

Instance Method Details

#notifications(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_notifications

List notifications for a given time range, optionally filtered by type (sms_notification, email_notification, phone_notification, or push_notification).

Parameters:

  • options (Sawyer::Resource) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :time_zone (String)

    Time zone in which dates in the result will be rendered.

  • :since (String)

    The start of the date range over which you want to search ISO8601 format

  • :until (String)

    The end of the date range over which you want to search ISO8601 format

  • :filter (Array<String>)

    Return only notifications with the given type (One of :sms_notification, :email_notification, :phone_notification, or :push_notification)

  • :include (Array<String>)

    Array of additional details to include. (One of users)

Returns:

  • (Array<Sawyer::Resource>)

    An array of hashes representing notifications

See Also:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pager_duty/client/notifications.rb', line 23

def notifications(options = {})
  query_params = Hash.new
  query_params[:time_zone]      = options[:time_zone] if options[:time_zone]
  query_params[:since] = options[:since].utc.iso8601 if options[:since]
  query_params[:until] = options[:until].utc.iso8601 if options[:until]
  query_params[:filter]        = options[:filter] if options[:filter]
  query_params[:include]       = options[:include] if options[:include]

  response = get "/notifications", options.merge({query: query_params})
  response[:notifications]
end