git.iko.soy/typeable/pagerduty
on develop help sign in
Adding additional structural skeletons for all pending REST APIs
commit4d55af3aa5fbac3b9dd7aee6be175db6d3924352 authorBrendan Hay <brendan.g.hay@gmail.com> dateTue 7 Oct 2014, 06:28 (12 years ago) parent6f8374d
15 files changed+219−37
pagerduty.cabal+9−9 src/Network/PagerDuty/Query.hs+10−10 src/Network/PagerDuty/REST.hs+4 src/Network/PagerDuty/REST/EscalationPolicies/OnCall.hs+28 src/Network/PagerDuty/REST/Incidents/Notes.hs+25 src/Network/PagerDuty/REST/MaintenanceWindows.hs+1−1 src/Network/PagerDuty/REST/Schedules.hs+1−1 src/Network/PagerDuty/REST/Schedules/Overrides.hs+5−6 src/Network/PagerDuty/REST/Services/EmailFilters.hs+29 src/Network/PagerDuty/REST/Users.hs+1−1 src/Network/PagerDuty/REST/Users/ContactMethods.hs+33 src/Network/PagerDuty/REST/Users/NotificationRules.hs+33 src/Network/PagerDuty/REST/Users/OnCall.hs+32 src/Network/PagerDuty/TH.hs+1−1 src/Network/PagerDuty/Types.hs+7−8
pagerduty.cabal+9−9
@@ -32,20 +32,20 @@ library
3232
3333 exposed-modules:
3434 Control.Monad.Trans.PagerDuty
35− , Network.PagerDuty.Integration
36− , Network.PagerDuty.REST
37− , Network.PagerDuty.REST.Alerts
38− , Network.PagerDuty.REST.EscalationPolicies
35+ -- , Network.PagerDuty.Integration
36+ -- , Network.PagerDuty.REST
37+ -- , Network.PagerDuty.REST.Alerts
38+ -- , Network.PagerDuty.REST.EscalationPolicies
3939 , Network.PagerDuty.REST.EscalationPolicies.EscalationRules
4040 , Network.PagerDuty.REST.EscalationPolicies.OnCall
4141 , Network.PagerDuty.REST.Incidents
4242 , Network.PagerDuty.REST.Incidents.Notes
43− , Network.PagerDuty.REST.LogEntries
44− , Network.PagerDuty.REST.MaintenanceWindows
45− , Network.PagerDuty.REST.Reports
46− , Network.PagerDuty.REST.Schedules
43+ -- , Network.PagerDuty.REST.LogEntries
44+ -- , Network.PagerDuty.REST.MaintenanceWindows
45+ -- , Network.PagerDuty.REST.Reports
46+ -- , Network.PagerDuty.REST.Schedules
4747 , Network.PagerDuty.REST.Schedules.Overrides
48− , Network.PagerDuty.REST.Services
48+ -- , Network.PagerDuty.REST.Services
4949 , Network.PagerDuty.REST.Services.EmailFilters
5050 , Network.PagerDuty.REST.Users
5151 , Network.PagerDuty.REST.Users.ContactMethods
src/Network/PagerDuty/Query.hs+10−10
@@ -16,7 +16,7 @@
1616-- Portability : non-portable (GHC extensions)
1717
1818module Network.PagerDuty.Query
19− ( ToQuery (..)
19+ ( QueryValues (..)
2020 , gquery
2121 , gqueryWith
2222 ) where
@@ -35,25 +35,25 @@ import Generics.SOP
3535import Network.HTTP.Types
3636import Network.PagerDuty.Options
3737
38−class ToQuery a where
38+class QueryValues a where
3939 queryValues :: a -> [ByteString]
4040
4141 default queryValues :: ToByteString a => a -> [ByteString]
4242 queryValues = (:[]) . toByteString'
4343
44−instance ToQuery a => ToQuery (Maybe a) where
44+instance QueryValues a => QueryValues (Maybe a) where
4545 queryValues (Just x) = queryValues x
4646 queryValues Nothing = []
4747
48−instance ToQuery Text where
48+instance QueryValues Text where
4949 queryValues x = [Text.encodeUtf8 x]
5050
51−gquery :: forall a. (Generic a, HasDatatypeInfo a, All2 ToQuery (Code a))
51+gquery :: forall a. (Generic a, HasDatatypeInfo a, All2 QueryValues (Code a))
5252 => a
5353 -> Query
5454gquery = gqueryWith underscored
5555
56−gqueryWith :: forall a. (Generic a, HasDatatypeInfo a, All2 ToQuery (Code a))
56+gqueryWith :: forall a. (Generic a, HasDatatypeInfo a, All2 QueryValues (Code a))
5757 => Options
5858 -> a
5959 -> Query
@@ -61,7 +61,7 @@ gqueryWith o a = case datatypeInfo (Proxy :: Proxy a) of
6161 ADT _ _ cs -> go cs (from a)
6262 Newtype _ _ c -> go (c :* Nil) (from a)
6363 where
64− go :: (All2 ToQuery xss, SingI xss)
64+ go :: (All2 QueryValues xss, SingI xss)
6565 => NP ConstructorInfo xss
6666 -> SOP I xss
6767 -> Query
@@ -74,7 +74,7 @@ gqueryWith o a = case datatypeInfo (Proxy :: Proxy a) of
7474 f [(k, v)] = [(k, Just v)]
7575 f xs@((k,_):_) = let n = k <> "[]" in map (bimap (const n) Just) xs
7676
77−gctor :: All ToQuery xs
77+gctor :: All QueryValues xs
7878 => Options
7979 -> ConstructorInfo xs
8080 -> NP I xs
@@ -95,7 +95,7 @@ gctor o (Infix n _ _) (x :* y :* Nil) =
9595gctor _ (Infix _ _ _) _ =
9696 error "Network.PagerDuty.Generics.inaccessible"
9797
98−gfield :: ToQuery a
98+gfield :: QueryValues a
9999 => Options
100100 -> FieldInfo a
101101 -> I a
@@ -105,5 +105,5 @@ gfield o (FieldInfo f) (I a) =
105105 where
106106 k = BS.pack $ (fieldLabelModifier o) f
107107
108−p :: Proxy ToQuery
108+p :: Proxy QueryValues
109109p = Proxy
src/Network/PagerDuty/REST.hs+4
@@ -33,6 +33,10 @@ import Network.HTTP.Types
3333import Network.PagerDuty.IO
3434import Network.PagerDuty.Types
3535
36+-- | Make the type names consistent, for example:
37+-- Suffix with *Details or *Info for results
38+-- No suffix for requests if necessary
39+
3640send :: (MonadIO m, FromJSON b)
3741 => Auth s
3842 -> SubDomain
src/Network/PagerDuty/REST/EscalationPolicies/OnCall.hsnew file+28
@@ -0,0 +1,28 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.EscalationPolicies.OnCall
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | List all the existing escalation policies with currently on-call users.
15+--
16+-- If the start and end of an on-call object are null, then the user is always
17+-- on-call for an escalation policy level.
18+module Network.PagerDuty.REST.EscalationPolicies.OnCall
19+ (
20+ ) where
21+
22+import Control.Lens
23+import Data.Monoid
24+import Data.Text (Text)
25+import Data.Time
26+import Network.HTTP.Types
27+import Network.PagerDuty.TH
28+import Network.PagerDuty.Types
src/Network/PagerDuty/REST/Incidents/Notes.hsnew file+25
@@ -0,0 +1,25 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.Incidents.Notes
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | The Incident Notes API allows you to add notes to a specified incident.
15+module Network.PagerDuty.REST.Incidents.Notes
16+ (
17+ ) where
18+
19+import Control.Lens
20+import Data.Monoid
21+import Data.Text (Text)
22+import Data.Time
23+import Network.HTTP.Types
24+import Network.PagerDuty.TH
25+import Network.PagerDuty.Types
src/Network/PagerDuty/REST/MaintenanceWindows.hs+1−1
@@ -116,7 +116,7 @@ queryRequest ''ListWindows
116116lwQuery :: Lens' (Request ListWindows s b) (Maybe Text)
117117lwQuery = upd.lwQuery'
118118
119−-- | An array of service IDs, specifying services whose maintenance
119+-- | An list of service IDs, specifying services whose maintenance
120120-- windows shall be returned.
121121lwServiceIds :: Lens' (Request ListWindows s b) [ServiceId]
122122lwServiceIds = upd.lwServiceIds'._L
src/Network/PagerDuty/REST/Schedules.hs+1−1
@@ -240,7 +240,7 @@ class HasScheduleInfo a where
240240 sTimeZone :: Lens' a TimeZone
241241 -- | The current day in the schedule's time zone.
242242 sToday :: Lens' a UTCTime
243− -- | An array of all the escalation policies that uses this schedule.
243+ -- | An list of all the escalation policies that uses this schedule.
244244 sEscalationPolicies :: Lens' a [PolicyId]
245245
246246 sId = scheduleInfo.siId'
src/Network/PagerDuty/REST/Schedules/Overrides.hs+5−6
@@ -55,9 +55,8 @@ import Network.PagerDuty.REST.Users
5555import Network.PagerDuty.TH
5656import Network.PagerDuty.Types
5757
58−schedules, overrides :: Path
59−schedules = "schedules"
60−overrides = "overrides"
58+overrides :: ScheduleId -> Path
59+overrides i = "schedules" % i % "overrides"
6160
6261data Override = Override
6362 { _oId :: Maybe OverrideId
@@ -121,7 +120,7 @@ listOverrides i s u =
121120 , _lsUntil' = u
122121 , _lsEditable' = F
123122 , _lsOverflow' = F
124− } & path .~ schedules % i % overrides
123+ } & path .~ overrides i
125124
126125data CreateOverride = CreateOverride
127126 { _coStart' :: Date
@@ -166,7 +165,7 @@ createOverride i u s e =
166165 , _coStart' = s
167166 , _coEnd' = e
168167 } & meth .~ POST
169− & path .~ schedules % i % overrides
168+ & path .~ overrides i
170169
171170-- | Remove an override.
172171--
@@ -184,4 +183,4 @@ createOverride i u s e =
184183deleteOverride :: ScheduleId -> OverrideId -> Request Empty s Empty
185184deleteOverride i o = empty
186185 & meth .~ DELETE
187− & path .~ schedules % i % overrides % o
186+ & path .~ overrides i % o
src/Network/PagerDuty/REST/Services/EmailFilters.hsnew file+29
@@ -0,0 +1,29 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.Services.EmailFilters
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | Email Filters are a set of rules that are applied to triggering email's body,
15+-- subject and from address. It only applies to generic_email kind of
16+-- Services. The way multiple filters are combined depends on the
17+-- email_filter_mode attribute of the service.
18+module Network.PagerDuty.REST.Services.EmailFilters
19+ (
20+ ) where
21+
22+import Control.Lens
23+import Data.Monoid
24+import Data.Text (Text)
25+import Data.Time
26+import Network.HTTP.Types
27+import Network.PagerDuty.TH
28+import Network.PagerDuty.Types
29+
src/Network/PagerDuty/REST/Users.hs+1−1
@@ -102,7 +102,7 @@ listUsers = undefined
102102getUser = undefined
103103
104104-- | Get a user object with that user's current on-call status. If the on-call
105−-- object is an empty array, the user is never on-call.
105+-- object is an empty list, the user is never on-call.
106106--
107107-- If the start and end of an on-call object are null, then the user is always
108108-- on-call for an escalation policy level.
src/Network/PagerDuty/REST/Users/ContactMethods.hsnew file+33
@@ -0,0 +1,33 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.Users.ContactMethods
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | Contact methods describe the various channels (phone numbers, SMS numbers
15+-- and email addresses) used to contact a user when an incident is assigned to
16+-- the user.
17+--
18+-- Access and manipulate the contact methods for a user.
19+module Network.PagerDuty.REST.Users.ContactMethods
20+ (
21+ ) where
22+
23+import Control.Lens
24+import Data.Monoid
25+import Data.Text (Text)
26+import Data.Time
27+import Network.HTTP.Types
28+import Network.PagerDuty.TH
29+import Network.PagerDuty.Types
30+
31+users :: Path
32+users = "users"
33+
src/Network/PagerDuty/REST/Users/NotificationRules.hsnew file+33
@@ -0,0 +1,33 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.Users.NotificationRules
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | When a user is assigned an incident, the user's notification rules are
15+-- used to determine which contact method will be used to alert the user and how
16+-- long after the incident to do so.
17+--
18+-- Access and manipulate the notification rules for a user.
19+module Network.PagerDuty.REST.Users.NotificationRules
20+ (
21+ ) where
22+
23+import Control.Lens
24+import Data.Monoid
25+import Data.Text (Text)
26+import Data.Time
27+import Network.HTTP.Types
28+import Network.PagerDuty.TH
29+import Network.PagerDuty.Types
30+
31+users :: Path
32+users = "users"
33+
src/Network/PagerDuty/REST/Users/OnCall.hsnew file+32
@@ -0,0 +1,32 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TemplateHaskell #-}
3+
4+-- Module : Network.PagerDuty.REST.Users.OnCall
5+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- License : This Source Code Form is subject to the terms of
7+-- the Mozilla Public License, v. 2.0.
8+-- A copy of the MPL can be found in the LICENSE file or
9+-- you can obtain it at http://mozilla.org/MPL/2.0/.
10+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11+-- Stability : experimental
12+-- Portability : non-portable (GHC extensions)
13+
14+-- | List currently on-call users of your PagerDuty account, optionally
15+-- filtered by a search query.
16+--
17+-- If the start and end of an on-call object are null, then the user is always
18+-- on-call for an escalation policy level.
19+module Network.PagerDuty.REST.Users.OnCall
20+ (
21+ ) where
22+
23+import Control.Lens
24+import Data.Monoid
25+import Data.Text (Text)
26+import Data.Time
27+import Network.HTTP.Types
28+import Network.PagerDuty.TH
29+import Network.PagerDuty.Types
30+
31+users :: Path
32+users = "users"
src/Network/PagerDuty/TH.hs+1−1
@@ -71,7 +71,7 @@ deriveNullary = deriveNullaryWith underscored
7171deriveNullaryWith :: Options -> Name -> Q [Dec]
7272deriveNullaryWith o n = concat <$> sequence
7373 [ deriveJSONWith o n
74− , [d|instance ToQuery $(conT n) where queryValues = value . toJSON|]
74+ , [d|instance QueryValues $(conT n) where queryValues = value . toJSON|]
7575 ]
7676
7777deriveRecord :: Name -> Q [Dec]
src/Network/PagerDuty/Types.hs+7−8
@@ -83,7 +83,7 @@ newtype List a = L [a]
8383deriveJSON ''List
8484makePrisms ''List
8585
86−instance ToQuery a => ToQuery (List a) where
86+instance QueryValues a => QueryValues (List a) where
8787 queryValues (L xs) = concatMap queryValues xs
8888
8989newtype Bool' = B Bool
@@ -96,7 +96,7 @@ instance ToByteString Bool' where
9696 builder (B True) = "true"
9797 builder (B False) = "false"
9898
99−instance ToQuery Bool'
99+instance QueryValues Bool'
100100
101101pattern T = B True
102102pattern F = B False
@@ -116,7 +116,7 @@ instance ToByteString Date where
116116 builder (D d) = builder
117117 (formatTime defaultTimeLocale (iso8601DateFormat $ Just "%XZ") d)
118118
119−instance ToQuery Date
119+instance QueryValues Date
120120
121121newtype TZ = TZ TimeZone
122122 deriving (Eq, Show)
@@ -132,7 +132,7 @@ instance ToJSON TZ where
132132instance ToByteString TZ where
133133 builder (TZ tz) = builder (timeZoneName tz)
134134
135−instance ToQuery TZ
135+instance QueryValues TZ
136136
137137instance Default TZ where
138138 def = TZ utc
@@ -354,7 +354,7 @@ instance ToJSON (Key a) where
354354instance ToByteString (Key a) where
355355 builder (Key k) = builder k
356356
357−instance ToQuery (Key a)
357+instance QueryValues (Key a)
358358
359359instance QueryValueLike (Key a) where
360360 toQueryValue = Just . toByteString'
@@ -374,7 +374,7 @@ instance ToJSON (Id a) where
374374instance ToByteString (Id a) where
375375 builder (Id i) = builder i
376376
377−instance ToQuery (Id a)
377+instance QueryValues (Id a)
378378
379379instance QueryValueLike (Id a) where
380380 toQueryValue = Just . toByteString'
@@ -388,7 +388,6 @@ type RequesterId = Id "requester"
388388type RuleId = Id "rule"
389389type ScheduleId = Id "schedule"
390390type ServiceId = Id "service"
391−type TargetId = Id "target"
392391type UserId = Id "user"
393392type VendorId = Id "vendor"
394393type WindowId = Id "maintenance-window"
@@ -416,4 +415,4 @@ makePrisms ''Address
416415instance ToByteString Address where
417416 builder (Address a) = builder a
418417
419−instance ToQuery Address
418+instance QueryValues Address