@@ -125,20 +125,8 @@ module Network.PagerDuty.REST.Incidents
125125 , aAt
126126 , aObject
127127
128+ , HasIncident (..)
128129 , Incident
129− , iIncidentNumber
130− , iStatus
131− , iCreatedOn
132− , iHtmlUrl
133− , iIncidentKey
134− , iService
135− , iEscalationPolicy
136− , iAssignedTo
137− , iAcknowledgers
138− , iLastStatusChangeBy
139− , iLastStatusChangeOn
140− , iTriggerSummaryData
141− , iTriggerDetailsHtmlUrl
142130 ) where
143131
144132import Control.Applicative hiding (empty)
@@ -223,76 +211,104 @@ data Assignee = Assignee
223211deriveRecord ''Assignee
224212
225213data Incident = Incident
226− { _iIncidentNumber :: !Int
227− , _iStatus :: !IncidentStatus
228− , _iCreatedOn :: Date
229− , _iHtmlUrl :: Text
230− , _iIncidentKey :: Maybe IncidentKey
231− , _iService :: Object
232− , _iEscalationPolicy :: Maybe Object
233− , _iAssignedTo :: [Assignee]
234− , _iAcknowledgers :: [Assignee]
235− , _iLastStatusChangeBy :: Maybe Assignee
236− , _iLastStatusChangeOn :: Maybe Date
237− , _iTriggerSummaryData :: Object
238− , _iTriggerDetailsHtmlUrl :: Text
214+ { _iIncidentNumber' :: !Int
215+ , _iStatus' :: !IncidentStatus
216+ , _iCreatedOn' :: Date
217+ , _iHtmlUrl' :: Text
218+ , _iIncidentKey' :: Maybe IncidentKey
219+ , _iService' :: Object
220+ , _iEscalationPolicy' :: Maybe Object
221+ , _iAssignedTo' :: [Assignee]
222+ , _iAcknowledgers' :: [Assignee]
223+ , _iLastStatusChangeBy' :: Maybe Assignee
224+ , _iLastStatusChangeOn' :: Maybe Date
225+ , _iTriggerSummaryData' :: Object
226+ , _iTriggerDetailsHtmlUrl' :: Text
239227 } deriving (Eq, Show)
240228
241−deriveJSON ''Incident
242−
243−-- | The number of the incident. This is unique across your account.
244−makeLens "_iIncidentNumber" ''Incident
245−
246−-- | The current status of the incident. Valid statuses are:
247−makeLens "_iStatus" ''Incident
248−
249−-- | The date/time the incident was triggered.
250−iCreatedOn :: Lens' Incident UTCTime
251−iCreatedOn = lens _iCreatedOn (\i x -> i { _iCreatedOn = x }) . _D
252−
253−-- | The PagerDuty website URL where the incident can be viewed and further
254−-- actions taken. This is not the resource URL.
255−makeLens "_iHtmlUrl" ''Incident
256−
257−-- | The incident's de-duplication key. See the PagerDuty Integration API docs
258−-- for further details.
259−makeLens "_iIncidentKey" ''Incident
260−
261−-- | The PagerDuty service that the incident belongs to. The service will
262−-- contain fields of its own.
263−makeLens "_iService" ''Incident
264−
265−-- | The escalation policy that the incident belongs to. The policy will
266−-- contain fields of its own.
267−makeLens "_iEscalationPolicy" ''Incident
268−
269−-- | The list of assignments of the incident. An assignment is an object
270−-- containing the assigned user as well as the date/time the incident was assigned
271−-- to that user. The user will contain fields of its own. This list is empty if
272−-- the status of the incident is resolved.
273−makeLens "_iAssignedTo" ''Incident
274−
275−-- | The list of acknowledgements of the incident. An acknowledgement is an
276−-- object containing the acknowleding object (either a user or the integration
277−-- API) as well as the date/time the incident was acknowledged. This field is only
278−-- present if the status of the incident is acknowledged. This field is sorted in
279−-- ascending order by acknowledgement time.
280−makeLens "_iAcknowledgers" ''Incident
281−
282−-- | The user who is responsible for the incident's last status change. If the incident is in the acknowledged or resolved status, this will be the user that took the first acknowledged or resolved action. If the incident was automatically resolved (say through the Event Integration API), or if the incident is in the triggered state, this will be null. User fields are the same as in the assignedToUser field above.
283−makeLens "_iLastStatusChangeBy" ''Incident
284−
285−-- | The date/time the incident's status last changed.
286−iLastStatusChangeOn :: Lens' Incident (Maybe UTCTime)
287−iLastStatusChangeOn =
288− lens _iLastStatusChangeOn (\i x -> i { _iLastStatusChangeOn = x })
289− . mapping _D
290−
291−-- | Some condensed information regarding the initial event that triggered this incident. This data will be a set of key/value pairs that vary depending on what sort of event triggered the incident (email, Event API request, etc). For instance, if an email triggered the incident, then the triggerSummaryData will likely contain a subject. There are no guarantees on the full presence of this data for every incident.
292−makeLens "_iTriggerSummaryData" ''Incident
293−
294−-- | The PagerDuty website URL where the full details regarding the initial event that triggered this incident can be found. (This is not the resource URL.)
295−makeLens "_iTriggerDetailsHtmlUrl" ''Incident
229+deriveRecord ''Incident
230+
231+class HasIncident a where
232+ incident :: Lens' a Incident
233+
234+ -- | The number of the incident. This is unique across your account.
235+ iIncidentNumber :: Lens' a Int
236+
237+ -- | The current status of the incident. Valid statuses are:
238+ iStatus :: Lens' a IncidentStatus
239+
240+ -- | The date/time the incident was triggered.
241+ iCreatedOn :: Lens' a UTCTime
242+
243+ -- | The PagerDuty website URL where the incident can be viewed and further
244+ -- actions taken. This is not the resource URL.
245+ iHtmlUrl :: Lens' a Text
246+
247+ -- | The incident's de-duplication key. See the PagerDuty Integration API
248+ -- docs for further details.
249+ iIncidentKey :: Lens' a (Maybe IncidentKey)
250+
251+ -- | The PagerDuty service that the incident belongs to. The service will
252+ -- contain fields of its own.
253+ iService :: Lens' a Object
254+
255+ -- | The escalation policy that the incident belongs to. The policy will
256+ -- contain fields of its own.
257+ iEscalationPolicy :: Lens' a (Maybe Object)
258+
259+ -- | The list of assignments of the incident. An assignment is an object
260+ -- containing the assigned user as well as the date/time the incident was
261+ -- assigned to that user. The user will contain fields of its own.
262+ -- This list is empty if the status of the incident is resolved.
263+ iAssignedTo :: Lens' a [Assignee]
264+
265+ -- | The list of acknowledgements of the incident. An acknowledgement is an
266+ -- object containing the acknowleding object (either a user or the
267+ -- integration API) as well as the date/time the incident was acknowledged.
268+ -- This field is only present if the status of the incident is acknowledged.
269+ -- This field is sorted in ascending order by acknowledgement time.
270+ iAcknowledgers :: Lens' a [Assignee]
271+
272+ -- | The user who is responsible for the incident's last status change. If
273+ -- the incident is in the acknowledged or resolved status, this will be the user
274+ -- that took the first acknowledged or resolved action. If the incident was
275+ -- automatically resolved (say through the Event Integration API), or if the
276+ -- incident is in the triggered state, this will be null. User fields are the
277+ -- same as in the assignedToUser field above.
278+ iLastStatusChangeBy :: Lens' a (Maybe Assignee)
279+
280+ -- | The date/time the incident's status last changed.
281+ iLastStatusChangeOn :: Lens' a (Maybe UTCTime)
282+
283+ -- | Some condensed information regarding the initial event that triggered
284+ -- this incident. This data will be a set of key/value pairs that vary depending
285+ -- on what sort of event triggered the incident (email, Event API request,
286+ -- etc). For instance, if an email triggered the incident, then the
287+ -- triggerSummaryData will likely contain a subject. There are no guarantees
288+ -- o nthe full presence of this data for every incident.
289+ iTriggerSummaryData :: Lens' a Object
290+
291+ -- | The PagerDuty website URL where the full details regarding the initial
292+ -- event that triggered this incident can be found. (This is not the resource
293+ -- URL.)
294+ iTriggerDetailsHtmlUrl :: Lens' a Text
295+
296+ iIncidentNumber = incident.iIncidentNumber'
297+ iStatus = incident.iStatus'
298+ iCreatedOn = incident.iCreatedOn'._D
299+ iHtmlUrl = incident.iHtmlUrl'
300+ iIncidentKey = incident.iIncidentKey'
301+ iService = incident.iService'
302+ iEscalationPolicy = incident.iEscalationPolicy'
303+ iAssignedTo = incident.iAssignedTo'
304+ iAcknowledgers = incident.iAcknowledgers'
305+ iLastStatusChangeBy = incident.iLastStatusChangeBy'
306+ iLastStatusChangeOn = incident.iLastStatusChangeOn'.mapping _D
307+ iTriggerSummaryData = incident.iTriggerSummaryData'
308+ iTriggerDetailsHtmlUrl = incident.iTriggerDetailsHtmlUrl'
309+
310+instance HasIncident Incident where
311+ incident = id
296312
297313data ListIncidents = ListIncidents
298314 { _lsSince' :: Maybe Date