pagerduty-sdk 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +19 -19
- data/LICENSE +20 -20
- data/README.md +44 -44
- data/Rakefile +11 -11
- data/lib/pagerduty.rb +42 -42
- data/lib/pagerduty/core.rb +100 -94
- data/lib/pagerduty/models/agent.rb +5 -5
- data/lib/pagerduty/models/alert.rb +10 -10
- data/lib/pagerduty/models/alerts.rb +6 -6
- data/lib/pagerduty/models/assigneduser.rb +8 -8
- data/lib/pagerduty/models/channels.rb +44 -44
- data/lib/pagerduty/models/escalationpolicies.rb +129 -129
- data/lib/pagerduty/models/incident.rb +26 -26
- data/lib/pagerduty/models/incidents.rb +18 -18
- data/lib/pagerduty/models/integration.rb +9 -9
- data/lib/pagerduty/models/laststatuschangeby.rb +9 -9
- data/lib/pagerduty/models/log_entry.rb +22 -22
- data/lib/pagerduty/models/maintenance_window.rb +66 -66
- data/lib/pagerduty/models/note.rb +9 -9
- data/lib/pagerduty/models/notes.rb +7 -7
- data/lib/pagerduty/models/notification.rb +7 -7
- data/lib/pagerduty/models/report.rb +54 -54
- data/lib/pagerduty/models/resolvedbyuser.rb +9 -9
- data/lib/pagerduty/models/schedule.rb +124 -109
- data/lib/pagerduty/models/service.rb +9 -9
- data/lib/pagerduty/models/services.rb +53 -53
- data/lib/pagerduty/models/triggersummarydata.rb +6 -6
- data/lib/pagerduty/models/user.rb +75 -75
- data/lib/pagerduty/pagerduty.rb +1145 -1115
- data/lib/pagerduty/requests/alerts.rb +53 -53
- data/lib/pagerduty/requests/incident.rb +69 -69
- data/lib/pagerduty/requests/integration.rb +74 -74
- data/pagerduty-sdk.gemspec +26 -26
- metadata +3 -3
@@ -1,5 +1,5 @@
|
|
1
|
-
class Agent
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :type
|
5
|
-
end
|
1
|
+
class Agent
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :type
|
5
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
class Alert
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :id
|
5
|
-
attribute :type
|
6
|
-
attribute :started_at
|
7
|
-
attribute :user, Pagerduty::User
|
8
|
-
attribute :address
|
9
|
-
|
10
|
-
end
|
1
|
+
class Alert
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :id
|
5
|
+
attribute :type
|
6
|
+
attribute :started_at
|
7
|
+
attribute :user, Pagerduty::User
|
8
|
+
attribute :address
|
9
|
+
|
10
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class Alerts
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :alerts, Array[Alert]
|
5
|
-
|
6
|
-
end
|
1
|
+
class Alerts
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :alerts, Array[Alert]
|
5
|
+
|
6
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class AssignedUser
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :id
|
5
|
-
attribute :name
|
6
|
-
attribute :email
|
7
|
-
attribute :html_url
|
8
|
-
end
|
1
|
+
class AssignedUser
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :id
|
5
|
+
attribute :name
|
6
|
+
attribute :email
|
7
|
+
attribute :html_url
|
8
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
class Nagios
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :type
|
5
|
-
attribute :summary
|
6
|
-
attribute :host
|
7
|
-
attribute :service
|
8
|
-
attribute :state
|
9
|
-
attribute :details
|
10
|
-
end
|
11
|
-
|
12
|
-
class Api
|
13
|
-
include Virtus.model
|
14
|
-
|
15
|
-
attribute :type
|
16
|
-
attribute :summary
|
17
|
-
attribute :service_key
|
18
|
-
attribute :description
|
19
|
-
attribute :incident_key
|
20
|
-
attribute :details
|
21
|
-
end
|
22
|
-
|
23
|
-
class Email
|
24
|
-
include Virtus.model
|
25
|
-
|
26
|
-
attribute :type
|
27
|
-
attribute :summary
|
28
|
-
attribute :to
|
29
|
-
attribute :from
|
30
|
-
attribute :subject
|
31
|
-
attribute :body
|
32
|
-
attribute :content_type
|
33
|
-
attribute :raw_url
|
34
|
-
attribute :html_url
|
35
|
-
end
|
36
|
-
|
37
|
-
class WebTrigger
|
38
|
-
include Virtus.model
|
39
|
-
|
40
|
-
attribute :type
|
41
|
-
attribute :summary
|
42
|
-
attribute :subject
|
43
|
-
attribute :details
|
44
|
-
end
|
1
|
+
class Nagios
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :type
|
5
|
+
attribute :summary
|
6
|
+
attribute :host
|
7
|
+
attribute :service
|
8
|
+
attribute :state
|
9
|
+
attribute :details
|
10
|
+
end
|
11
|
+
|
12
|
+
class Api
|
13
|
+
include Virtus.model
|
14
|
+
|
15
|
+
attribute :type
|
16
|
+
attribute :summary
|
17
|
+
attribute :service_key
|
18
|
+
attribute :description
|
19
|
+
attribute :incident_key
|
20
|
+
attribute :details
|
21
|
+
end
|
22
|
+
|
23
|
+
class Email
|
24
|
+
include Virtus.model
|
25
|
+
|
26
|
+
attribute :type
|
27
|
+
attribute :summary
|
28
|
+
attribute :to
|
29
|
+
attribute :from
|
30
|
+
attribute :subject
|
31
|
+
attribute :body
|
32
|
+
attribute :content_type
|
33
|
+
attribute :raw_url
|
34
|
+
attribute :html_url
|
35
|
+
end
|
36
|
+
|
37
|
+
class WebTrigger
|
38
|
+
include Virtus.model
|
39
|
+
|
40
|
+
attribute :type
|
41
|
+
attribute :summary
|
42
|
+
attribute :subject
|
43
|
+
attribute :details
|
44
|
+
end
|
@@ -1,129 +1,129 @@
|
|
1
|
-
class RuleObject
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :id
|
5
|
-
attribute :name
|
6
|
-
attribute :type
|
7
|
-
attribute :email
|
8
|
-
attribute :time_zone
|
9
|
-
attribute :color
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
class EscalationService
|
14
|
-
include Virtus.model
|
15
|
-
|
16
|
-
attribute :id
|
17
|
-
attribute :name
|
18
|
-
attribute :service_url
|
19
|
-
attribute :service_key
|
20
|
-
attribute :auto_resolve_timeout
|
21
|
-
attribute :acknowledgement_timeout
|
22
|
-
attribute :created_at
|
23
|
-
attribute :deleted_at
|
24
|
-
attribute :status
|
25
|
-
attribute :last_incident_timestamp
|
26
|
-
attribute :email_incident_creation
|
27
|
-
attribute :incident_counts
|
28
|
-
attribute :email_filter_mode
|
29
|
-
attribute :type
|
30
|
-
end
|
31
|
-
|
32
|
-
class EscalationRule < Pagerduty
|
33
|
-
include Virtus.model
|
34
|
-
|
35
|
-
attribute :id
|
36
|
-
attribute :escalation_delay_in_minutes
|
37
|
-
attribute :rule_object, RuleObject
|
38
|
-
|
39
|
-
def hashify
|
40
|
-
self.attributes.inject({}) { |attrs, (k,v)|
|
41
|
-
v.class == RuleObject ? attrs[k] = v.to_hash : attrs[k] = v
|
42
|
-
attrs
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def parent_policy
|
47
|
-
escalation_policies.detect { |policy|
|
48
|
-
policy.escalation_rules.detect { |p| p.id == self.id }
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def delete
|
53
|
-
res = curl({
|
54
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
|
55
|
-
method: 'DELETE',
|
56
|
-
raw_response: true
|
57
|
-
})
|
58
|
-
|
59
|
-
res.code == '200' ? 'Successfully deleted' : JSON.parse(res.body)
|
60
|
-
end
|
61
|
-
|
62
|
-
def save
|
63
|
-
self.attributes = curl({
|
64
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
|
65
|
-
data: self.hashify,
|
66
|
-
method: 'PUT'
|
67
|
-
})['escalation_rule']
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
class EscalationPolicy < Pagerduty
|
73
|
-
include Virtus.model
|
74
|
-
|
75
|
-
attribute :id
|
76
|
-
attribute :name
|
77
|
-
attribute :description
|
78
|
-
attribute :escalation_rules, Array[EscalationRule]
|
79
|
-
attribute :services, Set[EscalationService]
|
80
|
-
attribute :num_loops
|
81
|
-
|
82
|
-
def save
|
83
|
-
self.escalation_rules = self.escalation_rules.map { |rule|
|
84
|
-
rule.class == EscalationRule ? rule.hashify : rule
|
85
|
-
}
|
86
|
-
|
87
|
-
saved_policy = EscalationPolicy.new(JSON.parse(curl({
|
88
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}",
|
89
|
-
data: { escalation_policy: self.attributes },
|
90
|
-
method: 'PUT'
|
91
|
-
}).body)['escalation_policy'])
|
92
|
-
|
93
|
-
self.attributes = saved_policy.attributes
|
94
|
-
end
|
95
|
-
|
96
|
-
def delete
|
97
|
-
res = curl({
|
98
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}",
|
99
|
-
method: 'DELETE',
|
100
|
-
raw_response: true
|
101
|
-
})
|
102
|
-
|
103
|
-
res.code == '204' ? 'Successfully deleted policy' : JSON.parse(res.body)
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
def add_escalation_rule(options={})
|
108
|
-
EscalationRule.new(JSON.parse(curl({
|
109
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}/escalation_rules",
|
110
|
-
data: { escalation_rule: options.hashify },
|
111
|
-
method: 'POST'
|
112
|
-
}).body)['escalation_rule'])
|
113
|
-
end
|
114
|
-
|
115
|
-
def update_escalation_rules(options={})
|
116
|
-
options[:rules] = options[:rules].map { |rule| rule.class == EscalationRule ? rule.hashify : rule }
|
117
|
-
|
118
|
-
JSON.parse(curl({
|
119
|
-
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}/escalation_rules",
|
120
|
-
data: { escalation_rules: options[:rules] },
|
121
|
-
method: 'PUT'
|
122
|
-
}).body)
|
123
|
-
end
|
124
|
-
|
125
|
-
def refresh
|
126
|
-
self.attributes = get_escalation_policy(id: self.id)
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
1
|
+
class RuleObject
|
2
|
+
include Virtus.model
|
3
|
+
|
4
|
+
attribute :id
|
5
|
+
attribute :name
|
6
|
+
attribute :type
|
7
|
+
attribute :email
|
8
|
+
attribute :time_zone
|
9
|
+
attribute :color
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class EscalationService
|
14
|
+
include Virtus.model
|
15
|
+
|
16
|
+
attribute :id
|
17
|
+
attribute :name
|
18
|
+
attribute :service_url
|
19
|
+
attribute :service_key
|
20
|
+
attribute :auto_resolve_timeout
|
21
|
+
attribute :acknowledgement_timeout
|
22
|
+
attribute :created_at
|
23
|
+
attribute :deleted_at
|
24
|
+
attribute :status
|
25
|
+
attribute :last_incident_timestamp
|
26
|
+
attribute :email_incident_creation
|
27
|
+
attribute :incident_counts
|
28
|
+
attribute :email_filter_mode
|
29
|
+
attribute :type
|
30
|
+
end
|
31
|
+
|
32
|
+
class EscalationRule < Pagerduty
|
33
|
+
include Virtus.model
|
34
|
+
|
35
|
+
attribute :id
|
36
|
+
attribute :escalation_delay_in_minutes
|
37
|
+
attribute :rule_object, RuleObject
|
38
|
+
|
39
|
+
def hashify
|
40
|
+
self.attributes.inject({}) { |attrs, (k,v)|
|
41
|
+
v.class == RuleObject ? attrs[k] = v.to_hash : attrs[k] = v
|
42
|
+
attrs
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def parent_policy
|
47
|
+
escalation_policies.detect { |policy|
|
48
|
+
policy.escalation_rules.detect { |p| p.id == self.id }
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete
|
53
|
+
res = curl({
|
54
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
|
55
|
+
method: 'DELETE',
|
56
|
+
raw_response: true
|
57
|
+
})
|
58
|
+
|
59
|
+
res.code == '200' ? 'Successfully deleted' : JSON.parse(res.body)
|
60
|
+
end
|
61
|
+
|
62
|
+
def save
|
63
|
+
self.attributes = curl({
|
64
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
|
65
|
+
data: self.hashify,
|
66
|
+
method: 'PUT'
|
67
|
+
})['escalation_rule']
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class EscalationPolicy < Pagerduty
|
73
|
+
include Virtus.model
|
74
|
+
|
75
|
+
attribute :id
|
76
|
+
attribute :name
|
77
|
+
attribute :description
|
78
|
+
attribute :escalation_rules, Array[EscalationRule]
|
79
|
+
attribute :services, Set[EscalationService]
|
80
|
+
attribute :num_loops
|
81
|
+
|
82
|
+
def save
|
83
|
+
self.escalation_rules = self.escalation_rules.map { |rule|
|
84
|
+
rule.class == EscalationRule ? rule.hashify : rule
|
85
|
+
}
|
86
|
+
|
87
|
+
saved_policy = EscalationPolicy.new(JSON.parse(curl({
|
88
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}",
|
89
|
+
data: { escalation_policy: self.attributes },
|
90
|
+
method: 'PUT'
|
91
|
+
}).body)['escalation_policy'])
|
92
|
+
|
93
|
+
self.attributes = saved_policy.attributes
|
94
|
+
end
|
95
|
+
|
96
|
+
def delete
|
97
|
+
res = curl({
|
98
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}",
|
99
|
+
method: 'DELETE',
|
100
|
+
raw_response: true
|
101
|
+
})
|
102
|
+
|
103
|
+
res.code == '204' ? 'Successfully deleted policy' : JSON.parse(res.body)
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
def add_escalation_rule(options={})
|
108
|
+
EscalationRule.new(JSON.parse(curl({
|
109
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}/escalation_rules",
|
110
|
+
data: { escalation_rule: options.hashify },
|
111
|
+
method: 'POST'
|
112
|
+
}).body)['escalation_rule'])
|
113
|
+
end
|
114
|
+
|
115
|
+
def update_escalation_rules(options={})
|
116
|
+
options[:rules] = options[:rules].map { |rule| rule.class == EscalationRule ? rule.hashify : rule }
|
117
|
+
|
118
|
+
JSON.parse(curl({
|
119
|
+
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{self.id}/escalation_rules",
|
120
|
+
data: { escalation_rules: options[:rules] },
|
121
|
+
method: 'PUT'
|
122
|
+
}).body)
|
123
|
+
end
|
124
|
+
|
125
|
+
def refresh
|
126
|
+
self.attributes = get_escalation_policy(id: self.id)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
class Pagerduty
|
2
|
-
class Incidents
|
3
|
-
|
4
|
-
class Incident
|
5
|
-
include Virtus.model
|
6
|
-
|
7
|
-
attribute :id
|
8
|
-
attribute :incident_number
|
9
|
-
attribute :created_on
|
10
|
-
attribute :status
|
11
|
-
attribute :html_url
|
12
|
-
attribute :incident_key
|
13
|
-
attribute :service, Service
|
14
|
-
attribute :escalation_policy, EscalationPolicy
|
15
|
-
attribute :assigned_to_user, AssignedUser
|
16
|
-
attribute :trigger_summary_data, TriggerSummaryData
|
17
|
-
attribute :trigger_details_html_url
|
18
|
-
attribute :trigger_type
|
19
|
-
attribute :last_status_change_on
|
20
|
-
attribute :last_status_change_by, LastStatusChangeBy
|
21
|
-
attribute :number_of_escalations
|
22
|
-
attribute :resolved_by_user, ResolvedByUser
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
1
|
+
class Pagerduty
|
2
|
+
class Incidents
|
3
|
+
|
4
|
+
class Incident
|
5
|
+
include Virtus.model
|
6
|
+
|
7
|
+
attribute :id
|
8
|
+
attribute :incident_number
|
9
|
+
attribute :created_on
|
10
|
+
attribute :status
|
11
|
+
attribute :html_url
|
12
|
+
attribute :incident_key
|
13
|
+
attribute :service, Service
|
14
|
+
attribute :escalation_policy, EscalationPolicy
|
15
|
+
attribute :assigned_to_user, AssignedUser
|
16
|
+
attribute :trigger_summary_data, TriggerSummaryData
|
17
|
+
attribute :trigger_details_html_url
|
18
|
+
attribute :trigger_type
|
19
|
+
attribute :last_status_change_on
|
20
|
+
attribute :last_status_change_by, LastStatusChangeBy
|
21
|
+
attribute :number_of_escalations
|
22
|
+
attribute :resolved_by_user, ResolvedByUser
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|