Module: PagerDuty::Client::OnCalls
- Included in:
- PagerDuty::Client
- Defined in:
- lib/pager_duty/client/on_calls.rb
Overview
An on-call represents a contiguous unit of time for which a [user](#resource_Users) will be on call for a given escalation policy and escalation rule.
This may be the result of that user always being on call for the escalation rule, or a block of time during which the computed result of a schedule on that escalation rule puts the user on call.
During an on-call, the user is expected to bear responsibility for responding to any notifications she receives and working to resolve the associated incident(s).
On-calls cannot be created directly through the API; they are the computed result of how escalation policies and schedules are configured.
The API provides read-only access to the on-calls generated by PagerDuty.
Instance Method Summary collapse
-
#on_calls(options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_on_calls)
An array of hashes representing notifications.
Instance Method Details
#on_calls(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_on_calls
Returns An array of hashes representing notifications.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pager_duty/client/on_calls.rb', line 36 def on_calls( = {}) user_ids = .fetch(:user_ids, []) escalation_policy_ids = .fetch(:escalation_policy_ids, []) schedule_ids = .fetch(:schedule_ids, []) query_params = Hash.new query_params[:time_zone] = [:time_zone] if [:time_zone] query_params[:since] = [:since].utc.iso8601 if [:since] query_params[:until] = [:until].utc.iso8601 if [:until] query_params[:earliest] = .fetch(:earliest, false) if [:earliest] query_params[:include] = [:include] if [:include] query_params["user_ids[]"] = user_ids.join(",") if user_ids.length > 0 query_params["escalation_policy_ids[]"] = escalation_policy_ids.join(",") if escalation_policy_ids.length > 0 query_params["schedule_ids[]"] = schedule_ids.join(",") if schedule_ids.length > 0 response = get "/oncalls", .merge({query: query_params}) response[:oncalls] end |