git.iko.soy/typeable/pagerduty
on develop help sign in
Adding Users/NotificationRules REST API
84700ddBrendan Hay
src/Network/PagerDuty/REST/EscalationPolicies.hs+5−5
@@ -76,7 +76,7 @@ policies :: Path
76policies = "escalation_policies"
76policies = "escalation_policies"
77
77
78data Policy = Policy
78data Policy = Policy
79− { _pId :: PolicyId
79+ { _pId :: EscalationPolicyId
80 , _pName :: Text
80 , _pName :: Text
81 , _pNumLoops :: !Int
81 , _pNumLoops :: !Int
82 , _pRules :: [Rule]
82 , _pRules :: [Rule]
@@ -170,7 +170,7 @@ cpEscalationRules = upd.cpEscalationRules'
170-- @POST \/escalation_policies@
170-- @POST \/escalation_policies@
171--
171--
172-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/create>
172-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/create>
173−createPolicy :: PolicyId
173+createPolicy :: EscalationPolicyId
174 -> Text -- ^ 'creName'
174 -> Text -- ^ 'creName'
175 -> [Rule] -- ^ 'creEscalationRules'
175 -> [Rule] -- ^ 'creEscalationRules'
176 -> Request CreatePolicy s Policy
176 -> Request CreatePolicy s Policy
@@ -189,7 +189,7 @@ createPolicy i n rs =
189-- @GET \/escalation_policies\/\:id@
189-- @GET \/escalation_policies\/\:id@
190--
190--
191-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/show>
191-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/show>
192−getPolicy :: PolicyId -> Request Empty s Policy
192+getPolicy :: EscalationPolicyId -> Request Empty s Policy
193getPolicy i = empty & path .~ policies % i & unwrap .~ key "escalation_policy"
193getPolicy i = empty & path .~ policies % i & unwrap .~ key "escalation_policy"
194
194
195data UpdatePolicy = UpdatePolicy
195data UpdatePolicy = UpdatePolicy
@@ -223,7 +223,7 @@ upEscalationRules = upd.upEscalationRules'
223-- @PUT \/escalation_policies\/\:id@
223-- @PUT \/escalation_policies\/\:id@
224--
224--
225-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/update>
225-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/update>
226−updatePolicy :: PolicyId -> Request UpdatePolicy s Policy
226+updatePolicy :: EscalationPolicyId -> Request UpdatePolicy s Policy
227updatePolicy i =
227updatePolicy i =
228 mk UpdatePolicy
228 mk UpdatePolicy
229 { _upName' = Nothing
229 { _upName' = Nothing
@@ -240,5 +240,5 @@ updatePolicy i =
240-- @DELETE \/escalation_policies\/\:id@
240-- @DELETE \/escalation_policies\/\:id@
241--
241--
242-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/delete>
242-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/delete>
243−deletePolicy :: PolicyId -> Request Empty s Empty
243+deletePolicy :: EscalationPolicyId -> Request Empty s Empty
244deletePolicy i = empty & meth .~ DELETE & path .~ policies % i
244deletePolicy i = empty & meth .~ DELETE & path .~ policies % i
src/Network/PagerDuty/REST/EscalationPolicies/EscalationRules.hs+10−8
@@ -77,7 +77,9 @@ import Network.PagerDuty.Types
77
77
78default (Path)
78default (Path)
79
79
80+-- FIXME: The lenses here need to operate over (Request x s b) using upd
81+
80−rules :: PolicyId -> Path
82+rules :: EscalationPolicyId -> Path
81rules p = "escalation_policies" % p % "escalation_rules"
83rules p = "escalation_policies" % p % "escalation_rules"
82
84
83data TargetType
85data TargetType
@@ -137,7 +139,7 @@ instance ToJSON Target where
137 TUser u -> ("user", toJSON u)
139 TUser u -> ("user", toJSON u)
138
140
139data Rule = Rule
141data Rule = Rule
140− { _rId :: RuleId
142+ { _rId :: EscalationRuleId
141 , _rEscalationDelayInMinutes :: !Int
143 , _rEscalationDelayInMinutes :: !Int
142 , _rTargets :: [Target]
144 , _rTargets :: [Target]
143 } deriving (Eq, Show)
145 } deriving (Eq, Show)
@@ -158,7 +160,7 @@ makeLens "_rTargets" ''Rule
158-- @GET \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
160-- @GET \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
159--
161--
160-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/list>
162-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/list>
161−listRules :: PolicyId -> Request Empty s [Rule]
163+listRules :: EscalationPolicyId -> Request Empty s [Rule]
162listRules p = empty & path .~ rules p
164listRules p = empty & path .~ rules p
163
165
164-- | Show the escalation rule for an existing escalation policy.
166-- | Show the escalation rule for an existing escalation policy.
@@ -166,7 +168,7 @@ listRules p = empty & path .~ rules p
166-- @GET \/escalation_policies\/:escalation_policy_id\/escalation_rules\/\:id@
168-- @GET \/escalation_policies\/:escalation_policy_id\/escalation_rules\/\:id@
167--
169--
168-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/show>
170-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/show>
169−getRule :: PolicyId -> RuleId -> Request Empty s Rule
171+getRule :: EscalationPolicyId -> EscalationRuleId -> Request Empty s Rule
170getRule p r = empty & path .~ rules p % r
172getRule p r = empty & path .~ rules p % r
171
173
172data CreateRule = CreateRule
174data CreateRule = CreateRule
@@ -194,7 +196,7 @@ makeLens "_crTargets" ''CreateRule
194-- @POST \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
196-- @POST \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
195--
197--
196-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/create>
198-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/create>
197−createRule :: PolicyId
199+createRule :: EscalationPolicyId
198 -> Int -- ^ 'crEscalationDelayInMinutes'
200 -> Int -- ^ 'crEscalationDelayInMinutes'
199 -> [TargetId] -- ^ 'crTargets'
201 -> [TargetId] -- ^ 'crTargets'
200 -> Request CreateRule s Rule
202 -> Request CreateRule s Rule
@@ -225,7 +227,7 @@ makeLens "_urEscalationRules" ''UpdateRules
225-- @PUT \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
227-- @PUT \/escalation_policies\/\:escalation_policy_id\/escalation_rules@
226--
228--
227-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/multi_update>
229-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/multi_update>
228−updateRules :: PolicyId
230+updateRules :: EscalationPolicyId
229 -> [TargetId] -- ^ 'urEscalationRules'
231 -> [TargetId] -- ^ 'urEscalationRules'
230 -> Request UpdateRules s [Rule]
232 -> Request UpdateRules s [Rule]
231updateRules p rs =
233updateRules p rs =
@@ -258,7 +260,7 @@ makeLens "_urTargets" ''UpdateRule
258-- @PUT \/escalation_policies\/\:escalation_policy_id\/escalation_rules\/\:id@
260-- @PUT \/escalation_policies\/\:escalation_policy_id\/escalation_rules\/\:id@
259--
261--
260-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/update>
262-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/update>
261−updateRule :: PolicyId -> RuleId -> Request UpdateRule s Rule
263+updateRule :: EscalationPolicyId -> EscalationRuleId -> Request UpdateRule s Rule
262updateRule p r =
264updateRule p r =
263 mk UpdateRule
265 mk UpdateRule
264 { _urEscalationDelayInMinutes = Nothing
266 { _urEscalationDelayInMinutes = Nothing
@@ -272,5 +274,5 @@ updateRule p r =
272-- @DELETE \/escalation_policies\/\:escalation_policy_id\/escalation_rules\/\:id@
274-- @DELETE \/escalation_policies\/\:escalation_policy_id\/escalation_rules\/\:id@
273--
275--
274-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/delete>
276-- /See:/ <http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/delete>
275−deleteRule :: PolicyId -> RuleId -> Request Empty s Empty
277+deleteRule :: EscalationPolicyId -> EscalationRuleId -> Request Empty s Empty
276deleteRule p r = empty & meth .~ DELETE & path .~ rules p % r
278deleteRule p r = empty & meth .~ DELETE & path .~ rules p % r
src/Network/PagerDuty/REST/Incidents.hs+3−3
@@ -503,7 +503,7 @@ data UpdateIncident = UpdateIncident
503 { _iiId :: IncidentId
503 { _iiId :: IncidentId
504 , _iiStatus :: Maybe UpdateStatus
504 , _iiStatus :: Maybe UpdateStatus
505 , _iiEscalationLevel :: Maybe Int
505 , _iiEscalationLevel :: Maybe Int
506− , _iiEscalationPolicy :: Maybe PolicyId
506+ , _iiEscalationPolicy :: Maybe EscalationPolicyId
507 , _iiAssignedToUser :: Maybe (CSV UserId)
507 , _iiAssignedToUser :: Maybe (CSV UserId)
508 } deriving (Eq, Show)
508 } deriving (Eq, Show)
509
509
@@ -595,7 +595,7 @@ acknowledgeIncidentBasic i =
595 empty & meth .~ PUT & path .~ incidents % i % "acknowledge"
595 empty & meth .~ PUT & path .~ incidents % i % "acknowledge"
596
596
597data ReassignIncident = ReassignIncident
597data ReassignIncident = ReassignIncident
598− { _riEscalationPolicy' :: Maybe PolicyId
598+ { _riEscalationPolicy' :: Maybe EscalationPolicyId
599 , _riEscalationLevel' :: Maybe Int
599 , _riEscalationLevel' :: Maybe Int
600 , _riAssignedToUser' :: Maybe (CSV UserId)
600 , _riAssignedToUser' :: Maybe (CSV UserId)
601 } deriving (Eq, Show)
601 } deriving (Eq, Show)
@@ -604,7 +604,7 @@ jsonRequest ''ReassignIncident
604
604
605-- | The ID of an escalation policy. Delegate the incident to this escalation
605-- | The ID of an escalation policy. Delegate the incident to this escalation
606-- policy.
606-- policy.
607−riEscalationPolicy :: Lens' (Request ReassignIncident s b) (Maybe PolicyId)
607+riEscalationPolicy :: Lens' (Request ReassignIncident s b) (Maybe EscalationPolicyId)
608riEscalationPolicy = upd.riEscalationPolicy'
608riEscalationPolicy = upd.riEscalationPolicy'
609
609
610-- | Escalate incident to this level in the escalation policy.
610-- | Escalate incident to this level in the escalation policy.
src/Network/PagerDuty/REST/Services.hs+6−6
@@ -187,7 +187,7 @@ data ServiceType
187deriveNullary ''ServiceType
187deriveNullary ''ServiceType
188
188
189data PolicyInfo = PolicyInfo
189data PolicyInfo = PolicyInfo
190− { _pinfoId :: PolicyId
190+ { _pinfoId :: EscalationPolicyId
191 , _pinfoName :: Text
191 , _pinfoName :: Text
192 } deriving (Eq, Show)
192 } deriving (Eq, Show)
193
193
@@ -322,7 +322,7 @@ listServices =
322
322
323data CreateService = CreateService
323data CreateService = CreateService
324 { _csName' :: Text
324 { _csName' :: Text
325− , _csEscalationPolicyId' :: PolicyId
325+ , _csEscalationPolicyId' :: EscalationPolicyId
326 , _csType' :: !ServiceType
326 , _csType' :: !ServiceType
327 , _csVendorId' :: Maybe VendorId
327 , _csVendorId' :: Maybe VendorId
328 , _csDescription' :: Maybe Text
328 , _csDescription' :: Maybe Text
@@ -351,7 +351,7 @@ csVendorId :: Lens' (Request CreateService s r) (Maybe VendorId)
351csVendorId = upd.csVendorId'
351csVendorId = upd.csVendorId'
352
352
353-- | The id of the escalation policy to be used by this service.
353-- | The id of the escalation policy to be used by this service.
354−csEscalationPolicyId :: Lens' (Request CreateService s r) PolicyId
354+csEscalationPolicyId :: Lens' (Request CreateService s r) EscalationPolicyId
355csEscalationPolicyId = upd.csEscalationPolicyId'
355csEscalationPolicyId = upd.csEscalationPolicyId'
356
356
357-- | The duration in seconds before an incidents acknowledged in this service
357-- | The duration in seconds before an incidents acknowledged in this service
@@ -377,7 +377,7 @@ csSeverityFilter = upd.csSeverityFilter'
377--
377--
378-- /See:/ <http://developer.pagerduty.com/documentation/rest/services/create>
378-- /See:/ <http://developer.pagerduty.com/documentation/rest/services/create>
379createService :: Text
379createService :: Text
380− -> PolicyId
380+ -> EscalationPolicyId
381 -> ServiceType
381 -> ServiceType
382 -> Request CreateService s Service
382 -> Request CreateService s Service
383createService n p t =
383createService n p t =
@@ -407,7 +407,7 @@ getService i = empty
407data UpdateService = UpdateService
407data UpdateService = UpdateService
408 { _usName' :: Maybe Text
408 { _usName' :: Maybe Text
409 , _usDescription' :: Maybe Text
409 , _usDescription' :: Maybe Text
410− , _usEscalationPolicyId' :: Maybe PolicyId
410+ , _usEscalationPolicyId' :: Maybe EscalationPolicyId
411 , _usAcknowledgementTimeout' :: Maybe Int
411 , _usAcknowledgementTimeout' :: Maybe Int
412 , _usAutoResolveTimeout' :: Maybe Int
412 , _usAutoResolveTimeout' :: Maybe Int
413 , _usSeverityFilter' :: Maybe SeverityFilter
413 , _usSeverityFilter' :: Maybe SeverityFilter
@@ -424,7 +424,7 @@ usDescription :: Lens' (Request UpdateService s r) (Maybe Text)
424usDescription = upd.usDescription'
424usDescription = upd.usDescription'
425
425
426-- | The id of the escalation policy to be used by this service.
426-- | The id of the escalation policy to be used by this service.
427−usEscalationPolicyId :: Lens' (Request UpdateService s r) (Maybe PolicyId)
427+usEscalationPolicyId :: Lens' (Request UpdateService s r) (Maybe EscalationPolicyId)
428usEscalationPolicyId = upd.usEscalationPolicyId'
428usEscalationPolicyId = upd.usEscalationPolicyId'
429
429
430-- | The duration in seconds before an incidents acknowledged in this service
430-- | The duration in seconds before an incidents acknowledged in this service
src/Network/PagerDuty/REST/Users.hs+1−1
@@ -144,7 +144,7 @@ instance HasUserInfo UserInfo where
144 userInfo = id
144 userInfo = id
145
145
146data PolicyInfo = PolicyInfo
146data PolicyInfo = PolicyInfo
147− { _piId :: PolicyId
147+ { _piId :: EscalationPolicyId
148 , _piName :: Text
148 , _piName :: Text
149 } deriving (Eq, Show)
149 } deriving (Eq, Show)
150
150
src/Network/PagerDuty/REST/Users/ContactMethods.hs+10−13
@@ -1,5 +1,8 @@
1+{-# LANGUAGE ExtendedDefaultRules #-}
1−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
2−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4+
5+{-# OPTIONS_GHC -fno-warn-type-defaults #-}
3
6
4-- Module : Network.PagerDuty.REST.Users.ContactMethods
7-- Module : Network.PagerDuty.REST.Users.ContactMethods
5-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
@@ -49,26 +52,19 @@ module Network.PagerDuty.REST.Users.ContactMethods
49 -- * Types
52 -- * Types
50 , ContactType (..)
53 , ContactType (..)
51
54
55+ , HasContact (..)
52 , Contact
56 , Contact
53− , cId
54− , cUserId
55− , cLabel
56− , cAddress
57− , cType
58− , cCountryCode
59− , cSendShortEmail
60− , cBlacklisted
61 ) where
57 ) where
62
58
63import Control.Lens
59import Control.Lens
64import Data.Aeson.Lens
60import Data.Aeson.Lens
65−import Data.Monoid
66import Data.Text (Text)
61import Data.Text (Text)
67−import Data.Time
68import Network.HTTP.Types
62import Network.HTTP.Types
69import Network.PagerDuty.TH
63import Network.PagerDuty.TH
70import Network.PagerDuty.Types
64import Network.PagerDuty.Types
71
65
66+default (Path)
67+
72contacts :: UserId -> Path
68contacts :: UserId -> Path
73contacts u = "users" % u % "contact_methods"
69contacts u = "users" % u % "contact_methods"
74
70
@@ -91,7 +87,8 @@ data Contact = Contact
91 , _cBlacklisted :: Maybe Bool'
87 , _cBlacklisted :: Maybe Bool'
92 } deriving (Eq, Show)
88 } deriving (Eq, Show)
93
89
94−deriveRecord ''Contact
90+deriveJSON ''Contact
91+makeClassy ''Contact
95
92
96-- | List existing contact methods for the specified user.
93-- | List existing contact methods for the specified user.
97--
94--
src/Network/PagerDuty/REST/Users/NotificationRules.hs+107−12
@@ -1,5 +1,8 @@
1+{-# LANGUAGE ExtendedDefaultRules #-}
1−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
2−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4+
5+{-# OPTIONS_GHC -fno-warn-type-defaults #-}
3
6
4-- Module : Network.PagerDuty.REST.Users.NotificationRules
7-- Module : Network.PagerDuty.REST.Users.NotificationRules
5-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
@@ -20,50 +23,142 @@
20-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules>
23-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules>
21module Network.PagerDuty.REST.Users.NotificationRules
24module Network.PagerDuty.REST.Users.NotificationRules
22 (
25 (
26+ -- * List Rules
27+ listRules
28+
29+ -- * Create Rule
30+ , CreateRule
31+ , createRule
32+ , crStartDelayInMinutes
33+ , crContactMethodId
34+
35+ -- * Get Rule
36+ , getRule
37+
38+ -- * Update Rule
39+ , UpdateRule
40+ , updateRule
41+ , urStartDelayInMinutes
42+ , urContactMethodId
43+
44+ -- * Delete Rule
45+ , deleteRule
46+
47+ -- * Types
48+ , Rule
49+ , rId
50+ , rStartDelayInMinutes
51+ , rContactMethod
23 ) where
52 ) where
24
53
25import Control.Lens
54import Control.Lens
26−import Data.Monoid
55+import Data.Aeson.Lens
27−import Data.Text (Text)
28−import Data.Time
29import Network.HTTP.Types
56import Network.HTTP.Types
57+import Network.PagerDuty.REST.Users.ContactMethods
30import Network.PagerDuty.TH
58import Network.PagerDuty.TH
31import Network.PagerDuty.Types
59import Network.PagerDuty.Types
32
60
33−users :: Path
61+default (Path)
34−users = "users"
62+
63+rules :: UserId -> Path
64+rules u = "users" % u % "notification_rules"
65+
66+data Rule = Rule
67+ { _rId :: NotificationRuleId
68+ , _rStartDelayInMinutes :: !Int
69+ , _rContactMethod :: Contact
70+ } deriving (Eq, Show)
71+
72+deriveJSON ''Rule
73+makeLenses ''Rule
74+
75+instance HasContact Rule where
76+ contact = rContactMethod
35
77
36-- | List existing notification rules for the specified user.
78-- | List existing notification rules for the specified user.
37--
79--
38-- @GET \/users\/\:user_id\/notification_rules@
80-- @GET \/users\/\:user_id\/notification_rules@
39--
81--
40-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/list>
82-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/list>
41−listNotificationRules
83+listRules :: UserId -> Request Empty s Rule
84+listRules u = empty & path .~ rules u
42
85
43-- | Get details for a notification rule.
86-- | Get details for a notification rule.
44--
87--
45-- @GET \/users\/\:user_id\/notification_rules\/\:id@
88-- @GET \/users\/\:user_id\/notification_rules\/\:id@
46--
89--
47-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/show>
90-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/show>
48−getNotificationRule
91+getRule :: UserId -> NotificationRuleId -> Request Empty s Rule
92+getRule u n = empty & path .~ rules u % n
93+
94+data CreateRule = CreateRule
95+ { _crStartDelayInMinutes' :: !Int
96+ , _crContactMethodId' :: ContactId
97+ } deriving (Eq, Show)
98+
99+jsonRequest ''CreateRule
100+
101+-- | Number of minutes it will take for the notification rule to be activated
102+-- (from the time the incident is assigned to the owning user) and an alert be
103+-- fired.
104+crStartDelayInMinutes :: Lens' (Request CreateRule s b) Int
105+crStartDelayInMinutes = upd.crStartDelayInMinutes'
106+
107+-- | The id of the contact method.
108+crContactMethodId :: Lens' (Request CreateRule s b) ContactId
109+crContactMethodId = upd.crContactMethodId'
49
110
50-- | Create a new notification rule for the specified user.
111-- | Create a new notification rule for the specified user.
51--
112--
52-- @POST \/users\/\:user_id\/notification_rules@
113-- @POST \/users\/\:user_id\/notification_rules@
53--
114--
54-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/create>
115-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/create>
55−createNotificationRule
116+createRule :: UserId -> ContactId -> Int -> Request CreateRule s Rule
117+createRule u c n =
118+ mk CreateRule
119+ { _crStartDelayInMinutes' = n
120+ , _crContactMethodId' = c
121+ } & meth .~ POST
122+ & path .~ rules u
123+ & unwrap .~ key "notification_rule"
124+
125+data UpdateRule = UpdateRule
126+ { _urStartDelayInMinutes' :: Maybe Int
127+ , _urContactMethodId' :: Maybe ContactId
128+ } deriving (Eq, Show)
129+
130+jsonRequest ''UpdateRule
131+
132+-- | Number of minutes it will take for the notification rule to be activated
133+-- (from the time the incident is assigned to the owning user) and an alert be
134+-- fired.
135+urStartDelayInMinutes :: Lens' (Request UpdateRule s b) (Maybe Int)
136+urStartDelayInMinutes = upd.urStartDelayInMinutes'
137+
138+-- | The id of the contact method.
139+urContactMethodId :: Lens' (Request UpdateRule s b) (Maybe ContactId)
140+urContactMethodId = upd.urContactMethodId'
56
141
57-- | Update an existing notification rule.
142-- | Update an existing notification rule.
58--
143--
59-- @PUT \/users\/\:user_id\/notification_rules\/\:id@
144-- @PUT \/users\/\:user_id\/notification_rules\/\:id@
60--
145--
61-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/update>
146-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/update>
62−updateNotificationRule
147+updateRule :: UserId -> NotificationRuleId -> Request UpdateRule s Rule
148+updateRule u r =
149+ mk UpdateRule
150+ { _urStartDelayInMinutes' = Nothing
151+ , _urContactMethodId' = Nothing
152+ } & meth .~ PUT
153+ & path .~ rules u % r
154+ & unwrap .~ key "notification_rule"
63
155
64-- | Remove a notification rule.
156-- | Remove a notification rule.
65--
157--
66-- @DELETE \/users\/\:user_id\/notification_rules\/\:id@
158-- @DELETE \/users\/\:user_id\/notification_rules\/\:id@
67--
159--
68-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/delete>
160-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/delete>
69−deleteNotificationRule
161+deleteRule :: UserId
162+ -> NotificationRuleId
163+ -> Request Empty s Empty
164+deleteRule u n = empty & meth .~ DELETE & path .~ rules u % n
src/Network/PagerDuty/Types.hs+16−15
@@ -397,21 +397,22 @@ instance QueryValues (Id a)
397instance QueryValueLike (Id a) where
397instance QueryValueLike (Id a) where
398 toQueryValue = Just . toByteString'
398 toQueryValue = Just . toByteString'
399
399
400−type AlertId = Id "alert"
400+type AlertId = Id "alert"
401−type ContactId = Id "contact"
401+type ContactId = Id "contact"
402−type EmailFilterId = Id "email-filter"
402+type EmailFilterId = Id "email-filter"
403+type EscalationPolicyId = Id "escalation-policy"
404+type EscalationRuleId = Id "escalation-rule"
403−type IncidentId = Id "incident"
405+type IncidentId = Id "incident"
404−type LogEntryId = Id "log-entry"
406+type LogEntryId = Id "log-entry"
405−type NoteId = Id "note"
407+type NoteId = Id "note"
408+type NotificationRuleId = Id "notification-rule"
406−type OverrideId = Id "schedule-override"
409+type OverrideId = Id "schedule-override"
407−type PolicyId = Id "escalation-policy"
408−type RequesterId = Id "requester"
410+type RequesterId = Id "requester"
409−type RuleId = Id "rule"
410−type ScheduleId = Id "schedule"
411+type ScheduleId = Id "schedule"
411−type ServiceId = Id "service"
412+type ServiceId = Id "service"
412−type UserId = Id "user"
413+type UserId = Id "user"
413−type VendorId = Id "vendor"
414+type VendorId = Id "vendor"
414−type WindowId = Id "maintenance-window"
415+type WindowId = Id "maintenance-window"
415
416
416data Empty = Empty
417data Empty = Empty
417
418