@@ -59,6 +59,7 @@ module Network.PagerDuty.REST.Reports
59import Control.Lens
59import Control.Lens
60import Data.Aeson.Lens
60import Data.Aeson.Lens
61import Data.ByteString.Builder (Builder)
61import Data.ByteString.Builder (Builder)
62import Network.PagerDuty.TH
63import Network.PagerDuty.TH
63import Network.PagerDuty.Types
64import Network.PagerDuty.Types
@@ -85,13 +86,13 @@ deriveQuery ''Report
86-- | Start of the date range over which you want to search. The time element
87-- | Start of the date range over which you want to search. The time element
87-- is optional.
88-- is optional.
88−rSince :: Lens' (Request Report s b) Date
89+rSince :: Lens' (Request Report s b) UTCTime
89−rSince = upd.rSince'
90+rSince = upd.rSince'._Date
91-- | The end of the date range over which you want to search. This should be
92-- | The end of the date range over which you want to search. This should be
92-- in the same format as since.
93-- in the same format as since.
93−rUntil :: Lens' (Request Report s b) Date
94+rUntil :: Lens' (Request Report s b) UTCTime
94−rUntil = upd.rUntil'
95+rUntil = upd.rUntil'._Date
96-- | Specifies the bucket duration for each summation.
97-- | Specifies the bucket duration for each summation.
@@ -112,7 +113,18 @@ data AlertReport = AlertReport
112 , _arNumberOfEmailAlerts :: !Int
113 , _arNumberOfEmailAlerts :: !Int
113 } deriving (Eq, Show)
114 } deriving (Eq, Show)
115−deriveRecord ''AlertReport
116+deriveJSON ''AlertReport
118+arStart :: Lens' AlertReport UTCTime
119+arStart = lens _arStart (\r x -> r { _arStart = x }) ._Date
121+arEnd :: Lens' AlertReport UTCTime
122+arEnd = lens _arEnd (\r x -> r { _arEnd = x }) ._Date
124+makeLens "_arNumberOfAlerts" ''AlertReport
125+makeLens "_arNumberOfPhoneAlerts" ''AlertReport
126+makeLens "_arNumberOfSmsAlerts" ''AlertReport
127+makeLens "_arNumberOfEmailAlerts" ''AlertReport
117data AlertTotals = AlertTotals
129data AlertTotals = AlertTotals
118 { _atAlerts :: [AlertReport]
130 { _atAlerts :: [AlertReport]
@@ -131,13 +143,13 @@ deriveRecord ''AlertTotals
131-- @GET \/reports\/alerts_per_time@
143-- @GET \/reports\/alerts_per_time@
133-- See: <http://developer.pagerduty.com/documentation/rest/reports/alerts_per_time>
145-- See: <http://developer.pagerduty.com/documentation/rest/reports/alerts_per_time>
134−alertsPerTime :: Date -- ^ 'rSince'
146+alertsPerTime :: UTCTime -- ^ 'rSince'
135− -> Date -- ^ 'rUntil'
147+ -> UTCTime -- ^ 'rUntil'
136 -> Request Report s AlertTotals
148 -> Request Report s AlertTotals
137alertsPerTime s u =
149alertsPerTime s u =
138 mk Report
150 mk Report
139− { _rSince' = s
151+ { _rSince' = Date s
140− , _rUntil' = u
152+ , _rUntil' = Date u
141 , _rRollup' = Monthly
153 , _rRollup' = Monthly
142 } & path .~ reports % "alerts_per_time"
154 } & path .~ reports % "alerts_per_time"
@@ -147,7 +159,15 @@ data IncidentReport = IncidentReport
147 , _irNumberOfIncidents :: !Int
159 , _irNumberOfIncidents :: !Int
148 } deriving (Eq, Show)
160 } deriving (Eq, Show)
162+deriveJSON ''IncidentReport
164+irStart :: Lens' IncidentReport UTCTime
165+irStart = lens _irStart (\r x -> r { _irStart = x }) . _Date
167+irEnd :: Lens' IncidentReport UTCTime
168+irEnd = lens _irEnd (\r x -> r { _irEnd = x }) . _Date
150−deriveRecord ''IncidentReport
170+makeLens "_irNumberOfIncidents" ''IncidentReport
152-- | Get high level statistics about the number of incidents created for the
172-- | Get high level statistics about the number of incidents created for the
153-- desired time period, summed daily, weekly or monthly.
173-- desired time period, summed daily, weekly or monthly.
@@ -155,13 +175,13 @@ deriveRecord ''IncidentReport
155-- @GET \/reports\/incidents_per_time@
175-- @GET \/reports\/incidents_per_time@
157-- See: <http://developer.pagerduty.com/documentation/rest/reports/incidents_per_time>
177-- See: <http://developer.pagerduty.com/documentation/rest/reports/incidents_per_time>
158−incidentsPerTime :: Date -- ^ 'rSince'
178+incidentsPerTime :: UTCTime -- ^ 'rSince'
159− -> Date -- ^ 'rUntil'
179+ -> UTCTime -- ^ 'rUntil'
160 -> Request Report s [IncidentReport]
180 -> Request Report s [IncidentReport]
161incidentsPerTime s u =
181incidentsPerTime s u =
162 mk Report
182 mk Report
163− { _rSince' = s
183+ { _rSince' = Date s
164− , _rUntil' = u
184+ , _rUntil' = Date u
165 , _rRollup' = Monthly
185 , _rRollup' = Monthly
166 } & path .~ reports % "incidents_per_time"
186 } & path .~ reports % "incidents_per_time"
167 & unwrap .~ key "incidents"
187 & unwrap .~ key "incidents"