git.iko.soy/typeable/pagerduty
on develop help sign in
.gitignore+1
since splitsnapshots
unifiedsplit
@@ -9,6 +9,7 @@
9cabal.sandbox.config
9cabal.sandbox.config
10
10
11# Dirs
11# Dirs
12+.stack-work
12cabal-dev
13cabal-dev
13bin
14bin
14dist
15dist
.travis.ymlnew file+30
@@ -0,0 +1,30 @@
1+sudo: false
2+
3+cache:
4+ apt: true
5+ directories:
6+ - ~/.stack
7+
8+branches:
9+ only:
10+ - master
11+ - develop
12+
13+before_install:
14+ - export PATH=/opt/ghc/$GHCVER/bin:$PATH
15+ - export PATH=~/.local/bin:$PATH
16+ - ./script/travis-lifecycle-before_install
17+
18+install:
19+ - ./script/travis-lifecycle-install
20+
21+script:
22+ - ./script/travis-lifecycle-script
23+
24+matrix:
25+ fast_finish: true
26+ include:
27+ - env: GHCVER=8.0.1
28+ addons: { apt: { packages: [ghc-8.0.1], sources: [hvr-ghc] } }
29+ - env: GHCVER=7.10.3
30+ addons: { apt: { packages: [ghc-7.10.3], sources: [hvr-ghc] } }
Makefiledeleted−20
@@ -1,20 +0,0 @@
1−FLAGS := -j --disable-documentation --disable-library-coverage
2−
3−build:
4− cabal build $(addprefix -,$(findstring j,$(MAKEFLAGS)))
5−
6−all:
7− make clean; make install && make build
8−
9−install: cabal.sandbox.config
10− cabal install $(FLAGS) --only-dependencies
11−
12−clean:
13− cabal clean
14− rm -rf cabal.sandbox.config .cabal-sandbox
15−
16−doc:
17− cabal haddock
18−
19−cabal.sandbox.config:
20− cabal sandbox init
README.md+14
@@ -0,0 +1,14 @@
1+# PagerDuty
2+
3+[![Build Status](https://travis-ci.org/brendanhay/amazonka.svg?branch=develop)](https://travis-ci.org/brendanhay/pagerduty)
4+
5+* [Contribute](#contribute)
6+* [Licence](#licence)
7+
8+## Contribute
9+
10+For any problems, comments, or feedback please create an issue [here on GitHub](https://github.com/brendanhay/pagerduty/issues).
11+
12+## Licence
13+
14+PagerDuty is released under the [Mozilla Public License Version 2.0](http://www.mozilla.org/MPL/).
pagerduty.cabal+30−20
@@ -1,24 +1,32 @@
1name: pagerduty
1name: pagerduty
2−version: 0.0.0
2+version: 0.0.8
3−synopsis: Pager Duty API Client
3+synopsis: Client library for PagerDuty Integration and REST APIs.
4homepage: http://github.com/brendanhay/pagerduty
4homepage: http://github.com/brendanhay/pagerduty
5license: OtherLicense
5license: OtherLicense
6license-file: LICENSE
6license-file: LICENSE
7author: Brendan Hay
7author: Brendan Hay
8maintainer: Brendan Hay <brendan.g.hay@gmail.com>
8maintainer: Brendan Hay <brendan.g.hay@gmail.com>
9−copyright: Copyright (c) 2013-2014 Brendan Hay, 2014 Kim Altintop
9+copyright: Copyright (c) 2013-2015 Brendan Hay, 2014 Kim Altintop
10−category: Network, Monitoring, Alerting
10+category: Network, PagerDuty, Monitoring
11build-type: Simple
11build-type: Simple
12cabal-version: >= 1.10
12cabal-version: >= 1.10
13
13
14description:
14description:
15+ PagerDuty is an alerting system for IT professionals. PagerDuty connects
16+ with a variety of systems (including monitoring tools and ticketing
17+ systems) and dispatches alerts via automated phone call, SMS and email.
18+
15− Client library for the the PagerDuty REST APIs documented here:
19+ This library implements the full PagerDuty Integration and REST APIs which
20+ are documented here:
16 .
21 .
17 * Integration API - <http://developer.pagerduty.com/documentation/integration>
22 * Integration API - <http://developer.pagerduty.com/documentation/integration>
23+ .
18 * REST API - <http://developer.pagerduty.com/documentation/rest>
24 * REST API - <http://developer.pagerduty.com/documentation/rest>
19 .
25 .
20 /Warning:/ This is an experimental preview release which is still under
26 /Warning:/ This is an experimental preview release which is still under
21 heavy development and not intended for public consumption, caveat emptor!
27 heavy development and not intended for public consumption, caveat emptor!
28+ .
29+ /Note:/ An alternative source for Haddock documentation can be found <http://brendanhay.nz/pagerduty here>.
22
30
23extra-source-files:
31extra-source-files:
24 README.md
32 README.md
@@ -60,28 +68,30 @@ library
60 , Network.PagerDuty.Internal.Query
68 , Network.PagerDuty.Internal.Query
61 , Network.PagerDuty.Internal.TH
69 , Network.PagerDuty.Internal.TH
62 , Network.PagerDuty.Internal.Types
70 , Network.PagerDuty.Internal.Types
71+ , Network.PagerDuty.Types
63
72
64 build-depends:
73 build-depends:
65− aeson > 0.7 && <= 0.8
74+ aeson >= 2.0
66− , base >= 4.5 && < 5.0
75+ , base >= 4.7 && < 5
67− , bifunctors >= 4
76+ , bifunctors >= 4.1
68 , bytestring >= 0.9
77 , bytestring >= 0.9
69 , bytestring-conversion >= 0.2.1
78 , bytestring-conversion >= 0.2.1
70− , conduit >= 0.5.5
79+ , conduit > 1.1
71 , data-default-class >= 0.0.1
80 , data-default-class >= 0.0.1
72 , exceptions >= 0.6
81 , exceptions >= 0.6
73− , generics-sop >= 0.1.0.2
82+ , generics-sop >= 0.5.0.0
74− , http-client >= 0.3.6
83+ , http-client >= 0.5 && < 1
75 , http-types >= 0.8
84 , http-types >= 0.8
76− , lens >= 4.0
85+ , lens >= 4.4
77− , lens-aeson >= 1.0
86+ , lens-aeson >= 1
78− , mmorph >= 1.0
87+ , mmorph >= 1
79− , monad-control >= 0.3.2
88+ , monad-control >= 1
80− , mtl >= 2.2.1
89+ , mtl >= 2.1.3.1
81− , old-locale >= 1.0.0.5
82 , template-haskell >= 2.2
90 , template-haskell >= 2.2
83 , text >= 1.1
91 , text >= 1.1
84− , time == 1.4.*
92+ , time >= 1.2
93+ , time-locale-compat >= 0.1.0.1
85− , transformers >= 0.4.1
94+ , transformers >= 0.2
95+ , transformers-compat >= 0.3
86− , transformers-base >= 0.4.1
96+ , transformers-base >= 0.4.2
87 , unordered-containers >= 0.2.3
97 , unordered-containers >= 0.2.3
script/generate-pagesdeleted−25
@@ -1,25 +0,0 @@
1−#!/usr/bin/env bash
2−
3−set -e
4−set -x
5−set -o errexit
6−
7−branch=$(git symbolic-ref -q HEAD)
8−branch=${branch##refs/heads/}
9−branch=${branch:-HEAD}
10−
11−cabal configure --disable-tests
12−
13−DOCDIR=`mktemp -d -t pages.XXXXXX`
14−cabal haddock --haddock-option=-o$DOCDIR
15−
16−HEAD=`git rev-parse HEAD`
17−
18−git checkout gh-pages
19−
20−mv $DOCDIR/* .
21−
22−git add *.html *.js *.css *.gif *.png
23−git commit -m "Generated documentation from $HEAD on $branch"
24−git push origin gh-pages
25−git checkout $branch
script/travis-lifecycle-before_installnew file+11
@@ -0,0 +1,11 @@
1+#!/usr/bin/env bash
2+
3+set -e
4+
5+mkdir -p ~/.local/bin
6+
7+curl -L https://www.stackage.org/stack/linux-x86_64 | \
8+ tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
9+
10+ghc --version
11+stack --version
script/travis-lifecycle-installnew file+13
@@ -0,0 +1,13 @@
1+#!/usr/bin/env bash
2+
3+set -e
4+
5+GHCVER=${GHCVER?"GHCVER needs to be set."}
6+
7+path=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
8+
9+$path/travis-timeout \
10+ stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml setup
11+
12+$path/travis-timeout \
13+ stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml test pagerduty --only-snapshot
script/travis-lifecycle-scriptnew file+9
@@ -0,0 +1,9 @@
1+#!/usr/bin/env bash
2+
3+set -e
4+
5+GHCVER=${GHCVER?"GHCVER needs to be set."}
6+
7+path=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
8+
9+stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml test pagerduty
script/travis-timeoutnew file+15
@@ -0,0 +1,15 @@
1+#!/usr/bin/env bash
2+
3+$* &
4+pidA=$!
5+minutes=0
6+
7+while true; do sleep 60; ((minutes++)); echo -e "\033[0;32m$minutes minute(s) elapsed running '$*'\033[0m."; done &
8+pidB=$!
9+wait $pidA
10+resA=$?
11+
12+echo -e "\033[0;32m'$*' exited with status ${resA}.\033[0m"
13+kill -9 $pidB
14+
15+exit $resA
script/upload-documentationdeleted−37
@@ -1,37 +0,0 @@
1−#!/usr/bin/env bash
2−
3−set -e
4−
5−package=${PWD##*/}
6−
7−echo "Package: ${package}"
8−read -p "Version: " version
9−read -p "Hackage user: " user
10−read -sp "Hackage password (not echoed): " password
11−
12−echo
13−echo "BUILDING"
14−echo
15−
16−cabal configure
17−cabal build
18−cabal haddock \
19− --hyperlink-source \
20− --html-location='/package/$pkg-$version/docs' \
21− --contents-location='/package/$pkg'
22−
23−echo
24−echo "ARCHIVING"
25−echo
26−
27−cd dist/doc/html
28−DDIR="${package}-${version}-docs"
29−cp -r "${package}" "${DDIR}" && gtar -c -v -z -Hustar -f "${DDIR}.tar.gz" "${DDIR}"
30−
31−echo
32−echo "UPLOADING"
33−echo
34−
35−curl -X PUT -H 'Content-Type: application/x-tar' \
36− -H 'Content-Encoding: gzip' --data-binary "@${DDIR}.tar.gz" \
37− "http://${user}:${password}@hackage.haskell.org/package/${package}-${version}/docs"
src/Control/Monad/Trans/PagerDuty.hs+15−50
@@ -3,12 +3,11 @@
3{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
6−{-# LANGUAGE TemplateHaskell #-}
7{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE UndecidableInstances #-}
7{-# LANGUAGE UndecidableInstances #-}
9
8
10-- Module : Control.Monad.Trans.PagerDuty
9-- Module : Control.Monad.Trans.PagerDuty
11−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
12-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
13-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
14-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -26,19 +25,6 @@ module Control.Monad.Trans.PagerDuty
26 -- * Running
25 -- * Running
27 , runPagerDutyT
26 , runPagerDutyT
28
27
29− -- * Configuration
30− -- ** Environment
31− , Env
32− , envDomain
33− , envAuth
34− , envManager
35− , envLogger
36− , scoped
37−
38− -- ** Logging
39− , Logger (..)
40− , debug
41−
42 -- * Integration events
28 -- * Integration events
43 , submit
29 , submit
44 , submitCatch
30 , submitCatch
@@ -49,45 +35,28 @@ module Control.Monad.Trans.PagerDuty
49 , paginate
35 , paginate
50 , paginateCatch
36 , paginateCatch
51
37
52− -- * Errors
53− , Error(..)
54− , _Internal
55− , _Integration
56− , _REST
57−
58− -- ** Integration
59− , IntegrationError
60− , status
61−
62− -- ** REST
63− , RESTError
64− , code
65−
66− -- ** Code
67− , Code (..)
68− , description
69−
70− -- ** Fields
71− , message
72− , errors
38+ -- ** Lifting errors
73−
74− -- ** Lifting
75 , hoistError
39 , hoistError
40+
41+ , module Network.PagerDuty.Types
76 ) where
42 ) where
77
43
78import Control.Applicative
44import Control.Applicative
45+import Control.Monad
79import Control.Monad.Base
46import Control.Monad.Base
80import Control.Monad.Catch
47import Control.Monad.Catch
81−import Control.Monad.Except
48+import Control.Monad.Except (MonadError (..))
82import Control.Monad.Morph
49import Control.Monad.Morph
83import Control.Monad.Reader
50import Control.Monad.Reader
84import Control.Monad.Trans.Control
51import Control.Monad.Trans.Control
52+import Control.Monad.Trans.Except
85import Data.Aeson
53import Data.Aeson
86import Data.Conduit
54import Data.Conduit
87import Network.PagerDuty.Integration (Event, Response)
55import Network.PagerDuty.Integration (Event, Response)
88import qualified Network.PagerDuty.Integration as Int
56import qualified Network.PagerDuty.Integration as Int
89import Network.PagerDuty.Internal.Types
57import Network.PagerDuty.Internal.Types
90import qualified Network.PagerDuty.REST as REST
58import qualified Network.PagerDuty.REST as REST
59+import Network.PagerDuty.Types
91
60
92-- | A convenient alias for 'PagerDutyT' 'IO'.
61-- | A convenient alias for 'PagerDutyT' 'IO'.
93type PagerDuty s = PagerDutyT s IO
62type PagerDuty s = PagerDutyT s IO
@@ -114,28 +83,24 @@ instance MonadBase b m => MonadBase b (PagerDutyT s m) where
114 {-# INLINE liftBase #-}
83 {-# INLINE liftBase #-}
115
84
116instance MonadTransControl (PagerDutyT s) where
85instance MonadTransControl (PagerDutyT s) where
117− newtype StT (PagerDutyT s) a = StTPDT
118− { unStT :: StT (ExceptT Error) (StT (ReaderT (Env s)) a)
86+ type StT (PagerDutyT s) a = StT (ExceptT Error) (StT (ReaderT (Env s)) a)
119− }
120
87
121 liftWith f = PagerDutyT $
88 liftWith f = PagerDutyT $
122 liftWith $ \g ->
89 liftWith $ \g ->
123− liftWith $ \h ->
90+ liftWith $ \h ->
124− f (liftM StTPDT . h . g . unPagerDutyT)
91+ f (h . g . unPagerDutyT)
125 {-# INLINE liftWith #-}
92 {-# INLINE liftWith #-}
126
93
127− restoreT = PagerDutyT . restoreT . restoreT . liftM unStT
94+ restoreT = PagerDutyT . restoreT . restoreT
128 {-# INLINE restoreT #-}
95 {-# INLINE restoreT #-}
129
96
130instance MonadBaseControl b m => MonadBaseControl b (PagerDutyT s m) where
97instance MonadBaseControl b m => MonadBaseControl b (PagerDutyT s m) where
131− newtype StM (PagerDutyT s m) a = StMPDT
132− { unStMPDT :: ComposeSt (PagerDutyT s) m a
98+ type StM (PagerDutyT s m) a = ComposeSt (PagerDutyT s) m a
133− }
134
99
135− liftBaseWith = defaultLiftBaseWith StMPDT
100+ liftBaseWith = defaultLiftBaseWith
136 {-# INLINE liftBaseWith #-}
101 {-# INLINE liftBaseWith #-}
137
102
138− restoreM = defaultRestoreM unStMPDT
103+ restoreM = defaultRestoreM
139 {-# INLINE restoreM #-}
104 {-# INLINE restoreM #-}
140
105
141instance MFunctor (PagerDutyT s) where
106instance MFunctor (PagerDutyT s) where
src/Network/PagerDuty/Integration.hs+12−6
@@ -6,7 +6,7 @@
6{-# LANGUAGE TemplateHaskell #-}
6{-# LANGUAGE TemplateHaskell #-}
7
7
8-- Module : Network.PagerDuty.Integration
8-- Module : Network.PagerDuty.Integration
9−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
9+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
10-- License : This Source Code Form is subject to the terms of
10-- License : This Source Code Form is subject to the terms of
11-- the Mozilla Public License, v. 2.0.
11-- the Mozilla Public License, v. 2.0.
12-- A copy of the MPL can be found in the LICENSE file or
12-- A copy of the MPL can be found in the LICENSE file or
@@ -56,7 +56,7 @@ module Network.PagerDuty.Integration
56 , Resolve
56 , Resolve
57 , resolve
57 , resolve
58
58
59− -- * Event fields
59+ -- * Fields
60 , HasServiceKey (..)
60 , HasServiceKey (..)
61 , HasIncidentKey (..)
61 , HasIncidentKey (..)
62 , HasDescription (..)
62 , HasDescription (..)
@@ -72,19 +72,23 @@ module Network.PagerDuty.Integration
72 , rsStatus
72 , rsStatus
73 , rsMessage
73 , rsMessage
74 , rsIncidentKey
74 , rsIncidentKey
75+
76+ , Generic
77+
78+ , module Network.PagerDuty.Types
75 ) where
79 ) where
76
80
77import Control.Lens
81import Control.Lens
78import Control.Monad.IO.Class
82import Control.Monad.IO.Class
79import Data.Aeson
83import Data.Aeson
80−import Data.Default.Class
81−import qualified Data.HashMap.Strict as Map
84+import qualified Data.Aeson.KeyMap as Map
82import Data.Text (Text)
85import Data.Text (Text)
83import Network.HTTP.Client (Manager)
86import Network.HTTP.Client (Manager)
84import qualified Network.HTTP.Client as Client
87import qualified Network.HTTP.Client as Client
85import Network.PagerDuty.Internal.IO
88import Network.PagerDuty.Internal.IO
86import Network.PagerDuty.Internal.TH
89import Network.PagerDuty.Internal.TH
87import Network.PagerDuty.Internal.Types
90import Network.PagerDuty.Internal.Types
91+import Network.PagerDuty.Types hiding (description, message)
88
92
89data Response = Response
93data Response = Response
90 { _rsStatus :: Text
94 { _rsStatus :: Text
@@ -287,6 +291,8 @@ submitWith :: MonadIO m
287 -> Event
291 -> Event
288 -> m (Either Error Response)
292 -> m (Either Error Response)
289submitWith m l e = request m l e $
293submitWith m l e = request m l e $
294+ Client.defaultRequest
290− def { Client.host = "events.pagerduty.com"
295+ { Client.host = "events.pagerduty.com"
291− , Client.path = "/generic/2010-04-15/create_event.json"
296+ , Client.path = "/generic/2010-04-15/create_event.json"
297+ , Client.method = "POST"
292 }
298 }
src/Network/PagerDuty/Internal/IO.hs+1−1
@@ -2,7 +2,7 @@
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3
3
4-- Module : Network.PagerDuty.Internal.IO
4-- Module : Network.PagerDuty.Internal.IO
5−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
5+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
6-- License : This Source Code Form is subject to the terms of
6-- License : This Source Code Form is subject to the terms of
7-- the Mozilla Public License, v. 2.0.
7-- the Mozilla Public License, v. 2.0.
8-- A copy of the MPL can be found in the LICENSE file or
8-- A copy of the MPL can be found in the LICENSE file or
src/Network/PagerDuty/Internal/Options.hs+4−4
@@ -1,5 +1,5 @@
1-- Module : Network.PagerDuty.Internal.Options
1-- Module : Network.PagerDuty.Internal.Options
2−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
2+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
3-- License : This Source Code Form is subject to the terms of
3-- License : This Source Code Form is subject to the terms of
4-- the Mozilla Public License, v. 2.0.
4-- the Mozilla Public License, v. 2.0.
5-- A copy of the MPL can be found in the LICENSE file or
5-- A copy of the MPL can be found in the LICENSE file or
@@ -14,9 +14,9 @@ module Network.PagerDuty.Internal.Options
14 , underscored
14 , underscored
15 ) where
15 ) where
16
16
17−import Data.Aeson.Types
17+import Data.Aeson.Types
18−import Data.Char
18+import Data.Char
19−import Data.List
19+import Data.List
20
20
21dropped :: Int -> Options -> Options
21dropped :: Int -> Options -> Options
22dropped n o = o
22dropped n o = o
src/Network/PagerDuty/Internal/Query.hs+14−12
@@ -1,12 +1,13 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE DefaultSignatures #-}
2{-# LANGUAGE DefaultSignatures #-}
3+{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE GADTs #-}
4{-# LANGUAGE GADTs #-}
4{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TupleSections #-}
7{-# LANGUAGE TupleSections #-}
7
8
8-- Module : Network.PagerDuty.Internal.Query
9-- Module : Network.PagerDuty.Internal.Query
9−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
10-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
11-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
12-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -23,14 +24,14 @@ module Network.PagerDuty.Internal.Query
23
24
24import Data.Aeson.Types
25import Data.Aeson.Types
25import Data.Bifunctor
26import Data.Bifunctor
26−import Data.ByteString (ByteString)
27+import Data.ByteString (ByteString)
27−import qualified Data.ByteString.Char8 as BS
28+import qualified Data.ByteString.Char8 as BS
28import Data.ByteString.Conversion
29import Data.ByteString.Conversion
29−import Data.Function (on)
30+import Data.Function (on)
30−import Data.List (groupBy)
31+import Data.List (groupBy)
31−import Data.Monoid ((<>))
32+import Data.Monoid ((<>))
32−import Data.Text (Text)
33+import Data.Text (Text)
33−import qualified Data.Text.Encoding as Text
34+import qualified Data.Text.Encoding as Text
34import Generics.SOP
35import Generics.SOP
35import Network.HTTP.Types
36import Network.HTTP.Types
36import Network.PagerDuty.Internal.Options
37import Network.PagerDuty.Internal.Options
@@ -58,14 +59,15 @@ gqueryWith :: forall a. (Generic a, HasDatatypeInfo a, All2 QueryValues (Code a)
58 -> a
59 -> a
59 -> Query
60 -> Query
60gqueryWith o a = case datatypeInfo (Proxy :: Proxy a) of
61gqueryWith o a = case datatypeInfo (Proxy :: Proxy a) of
61− ADT _ _ cs -> go cs (from a)
62+ ADT _ _ cs _ -> go cs (from a)
62− Newtype _ _ c -> go (c :* Nil) (from a)
63+ Newtype _ _ c -> go (c :* Nil) (from a)
63 where
64 where
64− go :: (All2 QueryValues xss, SingI xss)
65+ go :: (All2 QueryValues xss, SListI xss)
65 => NP ConstructorInfo xss
66 => NP ConstructorInfo xss
66 -> SOP I xss
67 -> SOP I xss
67 -> Query
68 -> Query
69+ go cs (SOP sop) =
68− go cs (SOP sop) = group . unI . hcollapse $ hcliftA2' p (gctor o) cs sop
70+ group . hcollapse $ hcliftA2' p (gctor o) cs sop
69
71
70 group :: [(ByteString, ByteString)] -> Query
72 group :: [(ByteString, ByteString)] -> Query
71 group = concatMap f . groupBy ((==) `on` fst)
73 group = concatMap f . groupBy ((==) `on` fst)
src/Network/PagerDuty/Internal/TH.hs+6−6
@@ -1,7 +1,7 @@
1{-# LANGUAGE TemplateHaskell #-}
1{-# LANGUAGE TemplateHaskell #-}
2
2
3-- Module : Network.PagerDuty.Internal.TH
3-- Module : Network.PagerDuty.Internal.TH
4−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
4+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
5-- License : This Source Code Form is subject to the terms of
5-- License : This Source Code Form is subject to the terms of
6-- the Mozilla Public License, v. 2.0.
6-- the Mozilla Public License, v. 2.0.
7-- A copy of the MPL can be found in the LICENSE file or
7-- A copy of the MPL can be found in the LICENSE file or
@@ -40,15 +40,15 @@ module Network.PagerDuty.Internal.TH
40
40
41import Control.Applicative
41import Control.Applicative
42import Control.Lens
42import Control.Lens
43−import qualified Data.Aeson.TH as Aeson
43+import qualified Data.Aeson.TH as Aeson
44import Data.Aeson.Types
44import Data.Aeson.Types
45−import Data.ByteString (ByteString)
45+import Data.ByteString (ByteString)
46−import qualified Data.Text.Encoding as Text
46+import qualified Data.Text.Encoding as Text
47import Generics.SOP.TH
47import Generics.SOP.TH
48import Language.Haskell.TH
48import Language.Haskell.TH
49import Network.HTTP.Types.QueryLike
49import Network.HTTP.Types.QueryLike
50−import Network.PagerDuty.Internal.Query
51import Network.PagerDuty.Internal.Options
50import Network.PagerDuty.Internal.Options
51+import Network.PagerDuty.Internal.Query
52
52
53jsonRequest :: Name -> Q [Dec]
53jsonRequest :: Name -> Q [Dec]
54jsonRequest n = concat <$> sequence
54jsonRequest n = concat <$> sequence
@@ -61,7 +61,7 @@ queryRequest :: Name -> Q [Dec]
61queryRequest n = concat <$> sequence
61queryRequest n = concat <$> sequence
62 [ deriveGeneric n
62 [ deriveGeneric n
63 , makeLenses n
63 , makeLenses n
64− , [d|instance ToJSON $(conT n) where toJSON = const (toJSON (object []))|]
64+ , [d|instance ToJSON $(conT n) where toJSON = const emptyObject|]
65 , [d|instance QueryLike $(conT n) where toQuery = gquery|]
65 , [d|instance QueryLike $(conT n) where toQuery = gquery|]
66 ]
66 ]
67
67
src/Network/PagerDuty/Internal/Types.hs+43−26
@@ -15,7 +15,7 @@
15{-# LANGUAGE ViewPatterns #-}
15{-# LANGUAGE ViewPatterns #-}
16
16
17-- Module : Network.PagerDuty.Internal.Types
17-- Module : Network.PagerDuty.Internal.Types
18−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
18+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
19-- License : This Source Code Form is subject to the terms of
19-- License : This Source Code Form is subject to the terms of
20-- the Mozilla Public License, v. 2.0.
20-- the Mozilla Public License, v. 2.0.
21-- A copy of the MPL can be found in the LICENSE file or
21-- A copy of the MPL can be found in the LICENSE file or
@@ -27,35 +27,33 @@
27module Network.PagerDuty.Internal.Types where
27module Network.PagerDuty.Internal.Types where
28
28
29import Control.Applicative
29import Control.Applicative
30−import Control.Lens hiding ((.=))
30+import Control.Lens hiding ((.=), Empty)
31import Control.Monad.IO.Class
31import Control.Monad.IO.Class
32−import Data.Aeson hiding (Error)
32+import Data.Aeson hiding (Error, Key)
33+import qualified Data.Aeson.KeyMap as Map
33import Data.Aeson.Types (Parser)
34import Data.Aeson.Types (Parser)
34import Data.ByteString (ByteString)
35import Data.ByteString (ByteString)
35import qualified Data.ByteString.Char8 as BS
36import qualified Data.ByteString.Char8 as BS
36import Data.ByteString.Conversion hiding (List)
37import Data.ByteString.Conversion hiding (List)
37import Data.Default.Class
38import Data.Default.Class
38import Data.Function (on)
39import Data.Function (on)
39−import qualified Data.HashMap.Strict as Map
40import Data.List (deleteBy, intersperse)
40import Data.List (deleteBy, intersperse)
41import Data.Monoid
41import Data.Monoid
42import Data.String
42import Data.String
43import Data.Text (Text)
43import Data.Text (Text)
44import qualified Data.Text as Text
44import qualified Data.Text as Text
45import qualified Data.Text.Encoding as Text
45import qualified Data.Text.Encoding as Text
46−import Data.Time
46+import Data.Time (UTCTime, TimeZone, formatTime, utc, timeZoneName)
47import GHC.TypeLits
47import GHC.TypeLits
48import Network.HTTP.Client (Manager)
48import Network.HTTP.Client (Manager)
49import Network.HTTP.Types
49import Network.HTTP.Types
50import Network.HTTP.Types.QueryLike
50import Network.HTTP.Types.QueryLike
51import Network.PagerDuty.Internal.Query
51import Network.PagerDuty.Internal.Query
52import Network.PagerDuty.Internal.TH
52import Network.PagerDuty.Internal.TH
53−import System.Locale
53+import Data.Time.Locale.Compat
54−
55−-- FIXME: Verify IncidentId/IncidentKey .. *Id/*Key are actually different or needed
56
54
57newtype CSV a = CSV [a]
55newtype CSV a = CSV [a]
58− deriving (Eq, Show, Monoid)
56+ deriving (Eq, Show, Semigroup, Monoid)
59
57
60makePrisms ''CSV
58makePrisms ''CSV
61
59
@@ -72,7 +70,7 @@ instance ToByteString a => ToJSON (CSV a) where
72 toJSON = String . Text.decodeUtf8 . toByteString'
70 toJSON = String . Text.decodeUtf8 . toByteString'
73
71
74newtype List a = L [a]
72newtype List a = L [a]
75− deriving (Eq, Show, Monoid)
73+ deriving (Eq, Show, Semigroup, Monoid)
76
74
77deriveJSON ''List
75deriveJSON ''List
78makePrisms ''List
76makePrisms ''List
@@ -108,7 +106,7 @@ instance ToJSON Date where
108
106
109instance ToByteString Date where
107instance ToByteString Date where
110 builder (D d) = builder
108 builder (D d) = builder
111− (formatTime defaultTimeLocale (iso8601DateFormat $ Just "%XZ") d)
109+ (formatTime defaultTimeLocale ("%Y-%m-%dT%XZ") d)
112
110
113instance QueryValues Date
111instance QueryValues Date
114
112
@@ -135,14 +133,17 @@ data Security = Basic | Token
135 deriving (Eq, Show)
133 deriving (Eq, Show)
136
134
137data Auth (a :: Security) where
135data Auth (a :: Security) where
138− AuthBasic :: ByteString -> ByteString -> Auth Basic
136+ AuthBasic :: ByteString -> ByteString -> Auth 'Basic
139− AuthToken :: ByteString -> Auth Token
137+ AuthToken :: ByteString -> Auth 'Token
140
138
141deriving instance Eq (Auth a)
139deriving instance Eq (Auth a)
142deriving instance Show (Auth a)
140deriving instance Show (Auth a)
143
141
144newtype SubDomain = SubDomain { subDomain :: ByteString }
142newtype SubDomain = SubDomain { subDomain :: ByteString }
145− deriving (Eq, Show, IsString)
143+ deriving (Eq, Show, IsString, ToByteString)
144+
145+mkSubDomain :: ByteString -> SubDomain
146+mkSubDomain = SubDomain
146
147
147domain :: SubDomain -> ByteString
148domain :: SubDomain -> ByteString
148domain (SubDomain s)
149domain (SubDomain s)
@@ -179,7 +180,7 @@ prod :: SubDomain -> Auth s -> Manager -> Env s
179prod d a m = Env d a m None
180prod d a m = Env d a m None
180
181
181newtype Code = Code Integer
182newtype Code = Code Integer
182− deriving (Eq, Show)
183+ deriving (Eq, Show, Num)
183
184
184deriveJSON ''Code
185deriveJSON ''Code
185
186
@@ -278,8 +279,13 @@ data Pager = Pager
278
279
279makeLenses ''Pager
280makeLenses ''Pager
280
281
282+data Page a = Page
283+ { _pgItem :: a
284+ , _pgPager :: Maybe Pager
285+ }
286+
281−instance FromJSON a => FromJSON (a, Maybe Pager) where
287+instance FromJSON a => FromJSON (Page a) where
282− parseJSON = withObject "paginated" $ \o -> (,)
288+ parseJSON = withObject "paginated" $ \o -> Page
283 <$> parseJSON (Object o)
289 <$> parseJSON (Object o)
284 <*> optional (parse o)
290 <*> optional (parse o)
285 where
291 where
@@ -304,11 +310,13 @@ data Path where
304 Path :: Path
310 Path :: Path
305 Seg :: ToByteString a => a -> Path
311 Seg :: ToByteString a => a -> Path
306
312
313+instance Semigroup Path where
314+ x <> Path = x
315+ Path <> y = y
316+ Seg x <> Seg y = Seg (builder x <> "/" <> builder y)
317+
307instance Monoid Path where
318instance Monoid Path where
308− mempty = Path
319+ mempty = Path
309− mappend x Path = x
310− mappend Path y = y
311− mappend (Seg x) (Seg y) = Seg (builder x <> "/" <> builder y)
312
320
313instance IsString Path where
321instance IsString Path where
314 fromString = Seg
322 fromString = Seg
@@ -385,13 +393,13 @@ class Paginate a where
385 next :: Request a s b -> Maybe Pager -> Maybe (Request a s b)
393 next :: Request a s b -> Maybe Pager -> Maybe (Request a s b)
386 next rq = maybe Nothing go
394 next rq = maybe Nothing go
387 where
395 where
388− go x | x^.pgTotal == 0 = Nothing
396+ go x | x ^. pgTotal == 0 = Nothing
389− | otherwise = Just $
397+ | otherwise = Just $
390− rq & pager ?~ (x & pgOffset +~ x^.pgTotal)
398+ rq & pager ?~ (x & pgOffset +~ x ^. pgTotal)
391 & query %~ (add . clear)
399 & query %~ (add . clear)
392 where
400 where
393 add :: Query -> Query
401 add :: Query -> Query
394− add = maybe id ((:) . (k,) . Just . Text.encodeUtf8) (x^.pgQuery)
402+ add = maybe id ((:) . (k,) . Just . Text.encodeUtf8) (x ^. pgQuery)
395
403
396 clear :: Query -> Query
404 clear :: Query -> Query
397 clear = deleteBy ((==) `on` fst) (k, Nothing)
405 clear = deleteBy ((==) `on` fst) (k, Nothing)
@@ -402,6 +410,9 @@ class Paginate a where
402newtype Key (a :: Symbol) = Key Text
410newtype Key (a :: Symbol) = Key Text
403 deriving (Eq, Show, IsString)
411 deriving (Eq, Show, IsString)
404
412
413+mkKey :: Text -> Key a
414+mkKey = Key
415+
405instance FromJSON (Key a) where
416instance FromJSON (Key a) where
406 parseJSON = withText "key" (return . Key)
417 parseJSON = withText "key" (return . Key)
407
418
@@ -422,6 +433,9 @@ type IncidentKey = Key "incident"
422newtype Id (a :: Symbol) = Id Text
433newtype Id (a :: Symbol) = Id Text
423 deriving (Eq, Show, IsString)
434 deriving (Eq, Show, IsString)
424
435
436+mkId :: Text -> Id a
437+mkId = Id
438+
425instance FromJSON (Id a) where
439instance FromJSON (Id a) where
426 parseJSON = withText "id" (return . Id)
440 parseJSON = withText "id" (return . Id)
427
441
@@ -469,7 +483,10 @@ instance QueryLike Empty where
469 toQuery = const []
483 toQuery = const []
470
484
471newtype Address = Address Text
485newtype Address = Address Text
472− deriving (Eq, Show)
486+ deriving (Eq, Show, IsString)
487+
488+mkAddress :: Text -> Address
489+mkAddress = Address
473
490
474deriveJSON ''Address
491deriveJSON ''Address
475makePrisms ''Address
492makePrisms ''Address
src/Network/PagerDuty/REST.hs+16−25
@@ -2,7 +2,7 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3
3
4-- Module : Network.PagerDuty.REST
4-- Module : Network.PagerDuty.REST
5−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
5+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
6-- License : This Source Code Form is subject to the terms of
6-- License : This Source Code Form is subject to the terms of
7-- the Mozilla Public License, v. 2.0.
7-- the Mozilla Public License, v. 2.0.
8-- A copy of the MPL can be found in the LICENSE file or
8-- A copy of the MPL can be found in the LICENSE file or
@@ -13,22 +13,13 @@
13
13
14module Network.PagerDuty.REST
14module Network.PagerDuty.REST
15 (
15 (
16−
17 -- * Sending requests
16 -- * Sending requests
18 send
17 send
19− , paginate
20−
21− -- * Configuration
22− -- ** Environment
23− , Env
24− , envDomain
25− , envAuth
26− , envManager
27− , envLogger
28−
29− -- ** Requests
30 , sendWith
18 , sendWith
19+ , paginate
31 , paginateWith
20 , paginateWith
21+
22+ , module Network.PagerDuty.Types
32 ) where
23 ) where
33
24
34import Control.Applicative
25import Control.Applicative
@@ -36,20 +27,21 @@ import Control.Lens
36import Control.Monad
27import Control.Monad
37import Control.Monad.IO.Class
28import Control.Monad.IO.Class
38import Control.Monad.Trans
29import Control.Monad.Trans
39−import Data.Aeson (FromJSON)
30+import Data.Aeson (FromJSON)
40import Data.Conduit
31import Data.Conduit
41−import Data.Default.Class
42import Data.Monoid
32import Data.Monoid
43−import Network.HTTP.Client (Manager)
33+import Network.HTTP.Client (Manager)
44−import qualified Network.HTTP.Client as Client
34+import qualified Network.HTTP.Client as Client
45import Network.HTTP.Types
35import Network.HTTP.Types
46import Network.PagerDuty.Internal.IO
36import Network.PagerDuty.Internal.IO
47import Network.PagerDuty.Internal.Types
37import Network.PagerDuty.Internal.Types
38+import Network.PagerDuty.Types
48
39
49-- FIXME: verify correct actions are all paginated
40-- FIXME: verify correct actions are all paginated
50-- FIXME: Ensure RequesterId parameter is always most significant param
41-- FIXME: Ensure RequesterId parameter is always most significant param
51-- FIXME: add smart constructors for all types, for testing purposes
42-- FIXME: add smart constructors for all types, for testing purposes
52
43
44+-- | /See:/ 'sendWith'
53send :: (MonadIO m, FromJSON b)
45send :: (MonadIO m, FromJSON b)
54 => SubDomain
46 => SubDomain
55 -> Auth s
47 -> Auth s
@@ -58,13 +50,13 @@ send :: (MonadIO m, FromJSON b)
58 -> m (Either Error b)
50 -> m (Either Error b)
59send d a m = sendWith (prod d a m)
51send d a m = sendWith (prod d a m)
60
52
61−-- | /See:/ 'sendWith'
62sendWith :: (MonadIO m, FromJSON b)
53sendWith :: (MonadIO m, FromJSON b)
63 => Env s
54 => Env s
64 -> Request a s b
55 -> Request a s b
65 -> m (Either Error b)
56 -> m (Either Error b)
66−sendWith e = liftM (fmap fst) . http e
57+sendWith e = liftM (fmap _pgItem) . http e
67
58
59+-- | /See:/ 'paginateWith'
68paginate :: (MonadIO m, Paginate a, FromJSON b)
60paginate :: (MonadIO m, Paginate a, FromJSON b)
69 => SubDomain
61 => SubDomain
70 -> Auth s
62 -> Auth s
@@ -73,7 +65,6 @@ paginate :: (MonadIO m, Paginate a, FromJSON b)
73 -> Source m (Either Error b)
65 -> Source m (Either Error b)
74paginate d a m = paginateWith (prod d a m)
66paginate d a m = paginateWith (prod d a m)
75
67
76−-- | /See:/ 'paginateWith'
77paginateWith :: (MonadIO m, Paginate a, FromJSON b)
68paginateWith :: (MonadIO m, Paginate a, FromJSON b)
78 => Env s
69 => Env s
79 -> Request a s b
70 -> Request a s b
@@ -82,15 +73,15 @@ paginateWith e = go
82 where
73 where
83 go rq = do
74 go rq = do
84 rs <- lift (http e rq)
75 rs <- lift (http e rq)
85− yield (fst <$> rs)
76+ yield (_pgItem <$> rs)
86 either (const (return ()))
77 either (const (return ()))
87− (maybe (return ()) go . next rq . snd)
78+ (maybe (return ()) go . next rq . _pgPager)
88 rs
79 rs
89
80
90http :: (MonadIO m, FromJSON b)
81http :: (MonadIO m, FromJSON b)
91 => Env s
82 => Env s
92 -> Request a s b
83 -> Request a s b
93− -> m (Either Error (b, Maybe Pager))
84+ -> m (Either Error (Page b))
94http e rq = request (e ^. envManager) (e ^. envLogger) rq $ raw
85http e rq = request (e ^. envManager) (e ^. envLogger) rq $ raw
95 { Client.host = domain (e ^. envDomain)
86 { Client.host = domain (e ^. envDomain)
96 , Client.path = renderPath (rq ^. path)
87 , Client.path = renderPath (rq ^. path)
@@ -98,7 +89,7 @@ http e rq = request (e ^. envManager) (e ^. envLogger) rq $ raw
98 }
89 }
99 where
90 where
100 raw = case e ^. envAuth of
91 raw = case e ^. envAuth of
101− AuthBasic u p -> Client.applyBasicAuth u p def
92+ AuthBasic u p -> Client.applyBasicAuth u p Client.defaultRequest
102− AuthToken t -> def
93+ AuthToken t -> Client.defaultRequest
103 { Client.requestHeaders = [("Authorization", "Token token=" <> t)]
94 { Client.requestHeaders = [("Authorization", "Token token=" <> t)]
104 }
95 }
src/Network/PagerDuty/REST/Alerts.hs+7−7
@@ -4,7 +4,7 @@
4{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE TypeFamilies #-}
5
5
6-- Module : Network.PagerDuty.REST.Alerts
6-- Module : Network.PagerDuty.REST.Alerts
7−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
7+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
8-- License : This Source Code Form is subject to the terms of
8-- License : This Source Code Form is subject to the terms of
9-- the Mozilla Public License, v. 2.0.
9-- the Mozilla Public License, v. 2.0.
10-- A copy of the MPL can be found in the LICENSE file or
10-- A copy of the MPL can be found in the LICENSE file or
@@ -43,12 +43,12 @@ module Network.PagerDuty.REST.Alerts
43 , alertAddress
43 , alertAddress
44 ) where
44 ) where
45
45
46−import Control.Lens
46+import Control.Lens hiding (Empty)
47−import Data.Aeson.Lens
47+import Data.Aeson.Lens
48−import Data.Time
48+import Data.Time
49+import Network.PagerDuty.Internal.TH
50+import Network.PagerDuty.Internal.Types
49−import Network.PagerDuty.REST.Users (User)
51+import Network.PagerDuty.REST.Users (User)
50−import Network.PagerDuty.Internal.TH
51−import Network.PagerDuty.Internal.Types
52
52
53alerts :: Path
53alerts :: Path
54alerts = "alerts"
54alerts = "alerts"
src/Network/PagerDuty/REST/EscalationPolicies.hs+14−14
@@ -1,13 +1,13 @@
1+{-# LANGUAGE DataKinds #-}
1−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE DataKinds #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.EscalationPolicies
9-- Module : Network.PagerDuty.REST.EscalationPolicies
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -60,15 +60,15 @@ module Network.PagerDuty.REST.EscalationPolicies
60 , pServices
60 , pServices
61 ) where
61 ) where
62
62
63−import Control.Lens
63+import Control.Lens hiding (Empty)
64−import Data.Aeson.Lens
64+import Data.Aeson.Lens
65−import Data.Text (Text)
65+import Data.Text (Text)
66−import Network.HTTP.Types
66+import Network.HTTP.Types
67+import Network.PagerDuty.Internal.TH
68+import Network.PagerDuty.Internal.Types
67−import Network.PagerDuty.REST.Services (Service)
69+import Network.PagerDuty.REST.Services (Service)
68−import Network.PagerDuty.Internal.TH
69−import Network.PagerDuty.Internal.Types
70
70
71−import Network.PagerDuty.REST.EscalationPolicies.EscalationRules
71+import Network.PagerDuty.REST.EscalationPolicies.EscalationRules
72
72
73default (Path)
73default (Path)
74
74
src/Network/PagerDuty/REST/EscalationPolicies/EscalationRules.hs+10−10
@@ -1,12 +1,12 @@
1−{-# LANGUAGE ExtendedDefaultRules #-}
1+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5
5
6{-# OPTIONS_GHC -fno-warn-type-defaults #-}
6{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7
7
8-- Module : Network.PagerDuty.REST.EscalationPolicies.EscalationRules
8-- Module : Network.PagerDuty.REST.EscalationPolicies.EscalationRules
9−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
9+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
10-- License : This Source Code Form is subject to the terms of
10-- License : This Source Code Form is subject to the terms of
11-- the Mozilla Public License, v. 2.0.
11-- the Mozilla Public License, v. 2.0.
12-- A copy of the MPL can be found in the LICENSE file or
12-- A copy of the MPL can be found in the LICENSE file or
@@ -64,15 +64,15 @@ module Network.PagerDuty.REST.EscalationPolicies.EscalationRules
64 , rTargets
64 , rTargets
65 ) where
65 ) where
66
66
67−import Control.Applicative ((<$>))
67+import Control.Applicative ((<$>))
68−import Control.Lens hiding ((.=))
68+import Control.Lens hiding ((.=))
69import Data.Aeson
69import Data.Aeson
70−import qualified Data.HashMap.Strict as Map
70+import qualified Data.Aeson.KeyMap as Map
71−import Data.Text (Text)
71+import Data.Text (Text)
72import Network.HTTP.Types
72import Network.HTTP.Types
73−import Network.PagerDuty.REST.Users
74import Network.PagerDuty.Internal.TH
73import Network.PagerDuty.Internal.TH
75import Network.PagerDuty.Internal.Types
74import Network.PagerDuty.Internal.Types
75+import Network.PagerDuty.REST.Users
76
76
77default (Path)
77default (Path)
78
78
src/Network/PagerDuty/REST/Incidents.hs+9−8
@@ -10,7 +10,7 @@
10{-# OPTIONS_GHC -fno-warn-type-defaults #-}
10{-# OPTIONS_GHC -fno-warn-type-defaults #-}
11
11
12-- Module : Network.PagerDuty.REST.Incidents
12-- Module : Network.PagerDuty.REST.Incidents
13−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
13+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
14-- License : This Source Code Form is subject to the terms of
14-- License : This Source Code Form is subject to the terms of
15-- the Mozilla Public License, v. 2.0.
15-- the Mozilla Public License, v. 2.0.
16-- A copy of the MPL can be found in the LICENSE file or
16-- A copy of the MPL can be found in the LICENSE file or
@@ -130,9 +130,10 @@ module Network.PagerDuty.REST.Incidents
130 ) where
130 ) where
131
131
132import Control.Applicative hiding (empty)
132import Control.Applicative hiding (empty)
133−import Control.Lens
133+import Control.Lens hiding (Empty)
134import Data.Aeson
134import Data.Aeson
135−import Data.ByteString.Conversion (ToByteString(..), toByteString')
135+import Data.ByteString.Conversion (ToByteString (..),
136+ toByteString')
136import Data.Default.Class
137import Data.Default.Class
137import Data.Maybe
138import Data.Maybe
138import Data.Monoid hiding (All)
139import Data.Monoid hiding (All)
@@ -436,12 +437,12 @@ cSince = upd.cSince'.mapping _D
436
437
437-- | The end of the date range over which you want to search.
438-- | The end of the date range over which you want to search.
438--
439--
439−-- /Note: If you leave off either since or until, a 30 day default range is
440+-- /Note:/ If you leave off either since or until, a 30 day default range is
440-- applied to your open ended range. Not including the since parameter will set
441-- applied to your open ended range. Not including the since parameter will set
441−-- the date range to until - 30 days. Likewise, if you leave off until,
442+-- the date range to until @-30@ days. Likewise, if you leave off until,
442−-- it is set to since + 30 days.
443+-- it is set to since @+30@ days.
443--
444--
444−-- Defaults to the last 30 days if you leave off both. The size of the date
445+-- /Default:/ The last 30 days if you leave off both. The size of the date
445-- range must be less than 180 days.
446-- range must be less than 180 days.
446cUntil :: Lens' (Request CountIncidents s b) (Maybe UTCTime)
447cUntil :: Lens' (Request CountIncidents s b) (Maybe UTCTime)
447cUntil = upd.cUntil'.mapping _D
448cUntil = upd.cUntil'.mapping _D
@@ -566,7 +567,7 @@ updateIncidents r = auth updateIncidentsBasic & query .~ [("requester_id", r)]
566
567
567-- | A version of 'updateIncidents' which uses HTTP Basic authentication and
568-- | A version of 'updateIncidents' which uses HTTP Basic authentication and
568-- doesn't require a 'RequesterId'.
569-- doesn't require a 'RequesterId'.
569−updateIncidentsBasic :: Request UpdateIncidents Basic [UpdatedIncidents]
570+updateIncidentsBasic :: Request UpdateIncidents 'Basic [UpdatedIncidents]
570updateIncidentsBasic =
571updateIncidentsBasic =
571 mk UpdateIncidents
572 mk UpdateIncidents
572 { _uiIncidents' = []
573 { _uiIncidents' = []
src/Network/PagerDuty/REST/Incidents/Notes.hs+12−12
@@ -1,11 +1,11 @@
1−{-# LANGUAGE ExtendedDefaultRules #-}
1+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4
4
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
6
6
7-- Module : Network.PagerDuty.REST.Incidents.Notes
7-- Module : Network.PagerDuty.REST.Incidents.Notes
8−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
9-- License : This Source Code Form is subject to the terms of
9-- License : This Source Code Form is subject to the terms of
10-- the Mozilla Public License, v. 2.0.
10-- the Mozilla Public License, v. 2.0.
11-- A copy of the MPL can be found in the LICENSE file or
11-- A copy of the MPL can be found in the LICENSE file or
@@ -36,14 +36,14 @@ module Network.PagerDuty.REST.Incidents.Notes
36 , nContent
36 , nContent
37 ) where
37 ) where
38
38
39−import Control.Lens hiding ((.=))
39+import Control.Lens hiding ((.=))
40−import Data.Aeson
40+import Data.Aeson
41−import Data.Text (Text)
41+import Data.Text (Text)
42−import Data.Time
42+import Data.Time
43−import Network.HTTP.Types
43+import Network.HTTP.Types
44+import Network.PagerDuty.Internal.TH
45+import Network.PagerDuty.Internal.Types
44−import Network.PagerDuty.REST.Users
46+import Network.PagerDuty.REST.Users
45−import Network.PagerDuty.Internal.TH
46−import Network.PagerDuty.Internal.Types
47
47
48default (Path)
48default (Path)
49
49
src/Network/PagerDuty/REST/LogEntries.hs+6−7
@@ -5,7 +5,7 @@
5{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE TypeFamilies #-}
6
6
7-- Module : Network.PagerDuty.REST.LogEntries
7-- Module : Network.PagerDuty.REST.LogEntries
8−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
9-- License : This Source Code Form is subject to the terms of
9-- License : This Source Code Form is subject to the terms of
10-- the Mozilla Public License, v. 2.0.
10-- the Mozilla Public License, v. 2.0.
11-- A copy of the MPL can be found in the LICENSE file or
11-- A copy of the MPL can be found in the LICENSE file or
@@ -111,19 +111,18 @@ module Network.PagerDuty.REST.LogEntries
111 , nAddress
111 , nAddress
112 ) where
112 ) where
113
113
114−import Control.Applicative
114+import Control.Lens hiding (Empty)
115−import Control.Lens
116import Data.Aeson
115import Data.Aeson
117import Data.Aeson.Lens
116import Data.Aeson.Lens
117+import qualified Data.Aeson.KeyMap as Map
118import Data.Default.Class
118import Data.Default.Class
119−import qualified Data.HashMap.Strict as Map
120−import Data.Text (Text)
119+import Data.Text (Text)
121−import qualified Data.Text as Text
120+import qualified Data.Text as Text
122import Data.Time
121import Data.Time
123import Network.HTTP.Types
122import Network.HTTP.Types
124−import Network.PagerDuty.REST.Users (User)
125import Network.PagerDuty.Internal.TH
123import Network.PagerDuty.Internal.TH
126import Network.PagerDuty.Internal.Types
124import Network.PagerDuty.Internal.Types
125+import Network.PagerDuty.REST.Users (User)
127
126
128logs :: Path
127logs :: Path
129logs = "log_entries"
128logs = "log_entries"
src/Network/PagerDuty/REST/MaintenanceWindows.hs+10−10
@@ -4,7 +4,7 @@
4{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE TypeFamilies #-}
5
5
6-- Module : Network.PagerDuty.REST.MaintenanceWindows
6-- Module : Network.PagerDuty.REST.MaintenanceWindows
7−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
7+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
8-- License : This Source Code Form is subject to the terms of
8-- License : This Source Code Form is subject to the terms of
9-- the Mozilla Public License, v. 2.0.
9-- the Mozilla Public License, v. 2.0.
10-- A copy of the MPL can be found in the LICENSE file or
10-- A copy of the MPL can be found in the LICENSE file or
@@ -74,14 +74,14 @@ module Network.PagerDuty.REST.MaintenanceWindows
74 , mwServices
74 , mwServices
75 ) where
75 ) where
76
76
77−import Control.Lens
77+import Control.Lens hiding (Empty)
78−import Data.Monoid
78+import Data.Monoid
79−import Data.Text (Text)
79+import Data.Text (Text)
80−import Data.Time
80+import Data.Time
81−import Network.HTTP.Types
81+import Network.HTTP.Types
82+import Network.PagerDuty.Internal.TH
83+import Network.PagerDuty.Internal.Types
82−import Network.PagerDuty.REST.Users (User)
84+import Network.PagerDuty.REST.Users (User)
83−import Network.PagerDuty.Internal.TH
84−import Network.PagerDuty.Internal.Types
85
85
86windows :: Path
86windows :: Path
87windows = "maintenance_windows"
87windows = "maintenance_windows"
@@ -214,7 +214,7 @@ createWindow r s e xs =
214createWindowBasic :: UTCTime -- ^ 'cwStartTime'
214createWindowBasic :: UTCTime -- ^ 'cwStartTime'
215 -> UTCTime -- ^ 'cwEndTime'
215 -> UTCTime -- ^ 'cwEndTime'
216 -> [ServiceId] -- ^ 'cwServiceIds'
216 -> [ServiceId] -- ^ 'cwServiceIds'
217− -> Request CreateWindow Basic MaintenanceWindow
217+ -> Request CreateWindow 'Basic MaintenanceWindow
218createWindowBasic s e xs =
218createWindowBasic s e xs =
219 mk CreateWindow
219 mk CreateWindow
220 { _cwRequesterId' = Nothing
220 { _cwRequesterId' = Nothing
src/Network/PagerDuty/REST/Reports.hs+11−11
@@ -1,13 +1,13 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.Reports
9-- Module : Network.PagerDuty.REST.Reports
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -58,11 +58,11 @@ module Network.PagerDuty.REST.Reports
58 , irNumberOfIncidents
58 , irNumberOfIncidents
59 ) where
59 ) where
60
60
61−import Control.Lens
61+import Control.Lens hiding (Empty)
62−import Data.Aeson.Lens
62+import Data.Aeson.Lens
63−import Data.Time
63+import Data.Time
64−import Network.PagerDuty.Internal.TH
64+import Network.PagerDuty.Internal.TH
65−import Network.PagerDuty.Internal.Types
65+import Network.PagerDuty.Internal.Types
66
66
67default (Path)
67default (Path)
68
68
src/Network/PagerDuty/REST/Schedules.hs+14−14
@@ -1,13 +1,13 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.Schedules
9-- Module : Network.PagerDuty.REST.Schedules
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -110,14 +110,14 @@ module Network.PagerDuty.REST.Schedules
110 , sFinalSchedule
110 , sFinalSchedule
111 ) where
111 ) where
112
112
113−import Control.Lens hiding ((.=))
113+import Control.Lens hiding (Empty, (.=))
114−import Data.Aeson
114+import Data.Aeson
115−import Data.Text (Text)
115+import Data.Text (Text)
116−import Data.Time
116+import Data.Time
117−import Network.HTTP.Types
117+import Network.HTTP.Types
118+import Network.PagerDuty.Internal.TH
119+import Network.PagerDuty.Internal.Types
118−import Network.PagerDuty.REST.Users (User)
120+import Network.PagerDuty.REST.Users (User)
119−import Network.PagerDuty.Internal.TH
120−import Network.PagerDuty.Internal.Types
121
121
122default (Path)
122default (Path)
123
123
src/Network/PagerDuty/REST/Schedules/Overrides.hs+12−12
@@ -1,13 +1,13 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.Schedules
9-- Module : Network.PagerDuty.REST.Schedules
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -50,12 +50,12 @@ module Network.PagerDuty.REST.Schedules.Overrides
50 , oUser
50 , oUser
51 ) where
51 ) where
52
52
53−import Control.Lens
53+import Control.Lens
54−import Data.Time
54+import Data.Time
55−import Network.HTTP.Types
55+import Network.HTTP.Types
56+import Network.PagerDuty.Internal.TH
57+import Network.PagerDuty.Internal.Types
56−import Network.PagerDuty.REST.Users
58+import Network.PagerDuty.REST.Users
57−import Network.PagerDuty.Internal.TH
58−import Network.PagerDuty.Internal.Types
59
59
60overrides :: ScheduleId -> Path
60overrides :: ScheduleId -> Path
61overrides i = "schedules" % i % "overrides"
61overrides i = "schedules" % i % "overrides"
src/Network/PagerDuty/REST/Services.hs+16−16
@@ -1,13 +1,13 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.Services
9-- Module : Network.PagerDuty.REST.Services
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -106,14 +106,14 @@ module Network.PagerDuty.REST.Services
106 , svcSeverityFilter
106 , svcSeverityFilter
107 ) where
107 ) where
108
108
109−import Control.Lens
109+import Control.Lens hiding (Empty)
110−import Data.Aeson.Lens
110+import Data.Aeson.Lens
111−import Data.Text (Text)
111+import Data.Text (Text)
112−import Data.Time
112+import Data.Time
113−import Network.HTTP.Types
113+import Network.HTTP.Types
114+import Network.PagerDuty.Internal.TH
115+import Network.PagerDuty.Internal.Types
114−import Network.PagerDuty.REST.Services.EmailFilters
116+import Network.PagerDuty.REST.Services.EmailFilters
115−import Network.PagerDuty.Internal.TH
116−import Network.PagerDuty.Internal.Types
117
117
118default (Path)
118default (Path)
119
119
@@ -483,7 +483,7 @@ enableService r i =
483
483
484-- | A version of 'enableService' which uses HTTP Basic authentication and
484-- | A version of 'enableService' which uses HTTP Basic authentication and
485-- doesn't require a 'RequesterId'.
485-- doesn't require a 'RequesterId'.
486−enableServiceBasic :: ServiceId -> Request Empty Basic Empty
486+enableServiceBasic :: ServiceId -> Request Empty 'Basic Empty
487enableServiceBasic i = empty & meth .~ PUT & path .~ services % i % "enable"
487enableServiceBasic i = empty & meth .~ PUT & path .~ services % i % "enable"
488
488
489-- | Disable a service. Once a service is disabled, it will not be able to
489-- | Disable a service. Once a service is disabled, it will not be able to
@@ -498,7 +498,7 @@ disableService r i =
498
498
499-- | A version of 'disableService' which uses HTTP Basic authentication and
499-- | A version of 'disableService' which uses HTTP Basic authentication and
500-- doesn't require a 'RequesterId'.
500-- doesn't require a 'RequesterId'.
501−disableServiceBasic :: ServiceId -> Request Empty Basic Empty
501+disableServiceBasic :: ServiceId -> Request Empty 'Basic Empty
502disableServiceBasic i = empty & meth .~ PUT & path .~ services % i % "disable"
502disableServiceBasic i = empty & meth .~ PUT & path .~ services % i % "disable"
503
503
504-- | Regenerate a new service key for an existing service.
504-- | Regenerate a new service key for an existing service.
src/Network/PagerDuty/REST/Services/EmailFilters.hs+14−14
@@ -1,11 +1,11 @@
1−{-# LANGUAGE ExtendedDefaultRules #-}
1+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4
4
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
6
6
7-- Module : Network.PagerDuty.REST.Services.EmailFilters
7-- Module : Network.PagerDuty.REST.Services.EmailFilters
8−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
9-- License : This Source Code Form is subject to the terms of
9-- License : This Source Code Form is subject to the terms of
10-- the Mozilla Public License, v. 2.0.
10-- the Mozilla Public License, v. 2.0.
11-- A copy of the MPL can be found in the LICENSE file or
11-- A copy of the MPL can be found in the LICENSE file or
@@ -39,15 +39,15 @@ module Network.PagerDuty.REST.Services.EmailFilters
39 , efId
39 , efId
40 ) where
40 ) where
41
41
42−import Control.Applicative hiding (empty)
42+import Control.Applicative hiding (empty)
43−import Control.Lens hiding ((.=))
43+import Control.Lens hiding ((.=))
44−import Data.Aeson
44+import Data.Aeson
45−import Data.Default.Class
45+import Data.Default.Class
46−import Data.Monoid
46+import Data.Monoid
47−import Data.Text (Text)
47+import Data.Text (Text)
48−import Network.HTTP.Types
48+import Network.HTTP.Types
49−import Network.PagerDuty.Internal.TH
49+import Network.PagerDuty.Internal.TH
50−import Network.PagerDuty.Internal.Types
50+import Network.PagerDuty.Internal.Types
51
51
52default (Path)
52default (Path)
53
53
@@ -65,7 +65,7 @@ deriveNullaryWith hyphenated ''MatchMode
65-- FIXME: Tighten up this type! Make the regex required for match/no-match and
65-- FIXME: Tighten up this type! Make the regex required for match/no-match and
66-- encode the conditional invariants.
66-- encode the conditional invariants.
67data EmailFilterInfo = EmailFilterInfo
67data EmailFilterInfo = EmailFilterInfo
68− { _efSubjectMode' :: Maybe MatchMode
68+ { _efSubjectMode' :: Maybe MatchMode
69 , _efSubjectRegex' :: Maybe Text
69 , _efSubjectRegex' :: Maybe Text
70 , _efBodyMode' :: Maybe MatchMode
70 , _efBodyMode' :: Maybe MatchMode
71 , _efBodyRegex' :: Maybe Text
71 , _efBodyRegex' :: Maybe Text
src/Network/PagerDuty/REST/Users.hs+17−17
@@ -1,13 +1,13 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE ExtendedDefaultRules #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TemplateHaskell #-}
4+{-# LANGUAGE TemplateHaskell #-}
5−{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeFamilies #-}
6
6
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
7{-# OPTIONS_GHC -fno-warn-type-defaults #-}
8
8
9-- Module : Network.PagerDuty.REST.Users
9-- Module : Network.PagerDuty.REST.Users
10−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
10+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
11-- License : This Source Code Form is subject to the terms of
11-- License : This Source Code Form is subject to the terms of
12-- the Mozilla Public License, v. 2.0.
12-- the Mozilla Public License, v. 2.0.
13-- A copy of the MPL can be found in the LICENSE file or
13-- A copy of the MPL can be found in the LICENSE file or
@@ -81,16 +81,16 @@ module Network.PagerDuty.REST.Users
81 , uJobTitle
81 , uJobTitle
82 ) where
82 ) where
83
83
84−import Control.Applicative hiding (empty)
84+import Control.Applicative hiding (empty)
85−import Control.Lens hiding ((.=))
85+import Control.Lens hiding (Empty, (.=))
86−import Data.Aeson
86+import Data.Aeson
87−import Data.Default.Class
87+import Data.Default.Class
88−import Data.Monoid
88+import Data.Monoid
89−import Data.Text (Text)
89+import Data.Text (Text)
90−import Data.Time
90+import Data.Time
91−import Network.HTTP.Types
91+import Network.HTTP.Types
92−import Network.PagerDuty.Internal.TH
92+import Network.PagerDuty.Internal.TH
93−import Network.PagerDuty.Internal.Types
93+import Network.PagerDuty.Internal.Types
94
94
95default (Path)
95default (Path)
96
96
@@ -315,7 +315,7 @@ createUser r n e = auth (createUserBasic n e) & query .~ [("requester_id", r)]
315-- doesn't require a 'RequesterId'.
315-- doesn't require a 'RequesterId'.
316createUserBasic :: Text -- ^ 'cuName'
316createUserBasic :: Text -- ^ 'cuName'
317 -> Address -- ^ 'cuEmail'
317 -> Address -- ^ 'cuEmail'
318− -> Request CreateUser Basic User
318+ -> Request CreateUser 'Basic User
319createUserBasic n e =
319createUserBasic n e =
320 mk CreateUser
320 mk CreateUser
321 { _cuName' = n
321 { _cuName' = n
src/Network/PagerDuty/REST/Users/ContactMethods.hs+10−10
@@ -1,11 +1,11 @@
1−{-# LANGUAGE ExtendedDefaultRules #-}
1+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4
4
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
6
6
7-- Module : Network.PagerDuty.REST.Users.ContactMethods
7-- Module : Network.PagerDuty.REST.Users.ContactMethods
8−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
9-- License : This Source Code Form is subject to the terms of
9-- License : This Source Code Form is subject to the terms of
10-- the Mozilla Public License, v. 2.0.
10-- the Mozilla Public License, v. 2.0.
11-- A copy of the MPL can be found in the LICENSE file or
11-- A copy of the MPL can be found in the LICENSE file or
@@ -56,12 +56,12 @@ module Network.PagerDuty.REST.Users.ContactMethods
56 , Contact
56 , Contact
57 ) where
57 ) where
58
58
59−import Control.Lens
59+import Control.Lens
60−import Data.Aeson.Lens
60+import Data.Aeson.Lens
61−import Data.Text (Text)
61+import Data.Text (Text)
62−import Network.HTTP.Types
62+import Network.HTTP.Types
63−import Network.PagerDuty.Internal.TH
63+import Network.PagerDuty.Internal.TH
64−import Network.PagerDuty.Internal.Types
64+import Network.PagerDuty.Internal.Types
65
65
66default (Path)
66default (Path)
67
67
src/Network/PagerDuty/REST/Users/NotificationRules.hs+10−10
@@ -1,11 +1,11 @@
1−{-# LANGUAGE ExtendedDefaultRules #-}
1+{-# LANGUAGE ExtendedDefaultRules #-}
2−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE TemplateHaskell #-}
3+{-# LANGUAGE TemplateHaskell #-}
4
4
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
5{-# OPTIONS_GHC -fno-warn-type-defaults #-}
6
6
7-- Module : Network.PagerDuty.REST.Users.NotificationRules
7-- Module : Network.PagerDuty.REST.Users.NotificationRules
8−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
8+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
9-- License : This Source Code Form is subject to the terms of
9-- License : This Source Code Form is subject to the terms of
10-- the Mozilla Public License, v. 2.0.
10-- the Mozilla Public License, v. 2.0.
11-- A copy of the MPL can be found in the LICENSE file or
11-- A copy of the MPL can be found in the LICENSE file or
@@ -51,12 +51,12 @@ module Network.PagerDuty.REST.Users.NotificationRules
51 , rContactMethod
51 , rContactMethod
52 ) where
52 ) where
53
53
54−import Control.Lens
54+import Control.Lens
55−import Data.Aeson.Lens
55+import Data.Aeson.Lens
56−import Network.HTTP.Types
56+import Network.HTTP.Types
57+import Network.PagerDuty.Internal.TH
58+import Network.PagerDuty.Internal.Types
57−import Network.PagerDuty.REST.Users.ContactMethods
59+import Network.PagerDuty.REST.Users.ContactMethods
58−import Network.PagerDuty.Internal.TH
59−import Network.PagerDuty.Internal.Types
60
60
61default (Path)
61default (Path)
62
62
src/Network/PagerDuty/REST/Webhooks.hs+4−3
@@ -3,7 +3,7 @@
3{-# LANGUAGE TemplateHaskell #-}
3{-# LANGUAGE TemplateHaskell #-}
4
4
5-- Module : Network.PagerDuty.REST.Webhooks
5-- Module : Network.PagerDuty.REST.Webhooks
6−-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
6+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
7-- License : This Source Code Form is subject to the terms of
7-- License : This Source Code Form is subject to the terms of
8-- the Mozilla Public License, v. 2.0.
8-- the Mozilla Public License, v. 2.0.
9-- A copy of the MPL can be found in the LICENSE file or
9-- A copy of the MPL can be found in the LICENSE file or
@@ -35,13 +35,14 @@ module Network.PagerDuty.REST.Webhooks
35import Control.Applicative hiding (empty)
35import Control.Applicative hiding (empty)
36import Control.Lens
36import Control.Lens
37import Data.Aeson
37import Data.Aeson
38−import Data.ByteString.Conversion (ToByteString(..), toByteString')
38+import Data.ByteString.Conversion (ToByteString (..),
39+ toByteString')
39import Data.Text (Text)
40import Data.Text (Text)
40import qualified Data.Text.Encoding as Text
41import qualified Data.Text.Encoding as Text
41import Data.Time
42import Data.Time
42−import Network.PagerDuty.REST.Incidents
43import Network.PagerDuty.Internal.TH
43import Network.PagerDuty.Internal.TH
44import Network.PagerDuty.Internal.Types
44import Network.PagerDuty.Internal.Types
45+import Network.PagerDuty.REST.Incidents
45
46
46data WebhookType
47data WebhookType
47 = WTrigger
48 = WTrigger
src/Network/PagerDuty/Types.hsnew file+93
@@ -0,0 +1,93 @@
1+-- Module : Network.PagerDuty.Types
2+-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
3+-- License : This Source Code Form is subject to the terms of
4+-- the Mozilla Public License, v. 2.0.
5+-- A copy of the MPL can be found in the LICENSE file or
6+-- you can obtain it at http://mozilla.org/MPL/2.0/.
7+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
8+-- Stability : experimental
9+-- Portability : non-portable (GHC extensions)
10+
11+module Network.PagerDuty.Types
12+ (
13+ -- * Configuration
14+ -- ** Environment
15+ Env
16+ , envDomain
17+ , envAuth
18+ , envManager
19+ , envLogger
20+
21+ -- ** Logging
22+ , Logger (..)
23+ , debug
24+
25+ -- * Types
26+ -- ** Requests
27+ , Paginate
28+ , Request
29+
30+ -- ** Errors
31+ , Error
32+ , _Internal
33+ , _Integration
34+ , _REST
35+ -- *** Messages
36+ , HasMessage (..)
37+ -- *** Fields
38+ , HasErrors (..)
39+ -- *** Integration
40+ , IntegrationError
41+ , status
42+ -- *** REST
43+ , RESTError
44+ , Code
45+ , code
46+ , description
47+
48+ -- ** Authentication
49+ , Security (..)
50+ , Auth (..)
51+
52+ -- ** Keys
53+ , Key
54+ , mkKey
55+ -- *** Aliases
56+ , ServiceKey
57+ , IncidentKey
58+
59+ -- ** Identifiers
60+ , Id
61+ , mkId
62+ -- *** Aliases
63+ , AlertId
64+ , ContactId
65+ , EmailFilterId
66+ , EscalationPolicyId
67+ , EscalationRuleId
68+ , IncidentId
69+ , LogEntryId
70+ , NoteId
71+ , NotificationRuleId
72+ , OverrideId
73+ , RequesterId
74+ , ScheduleId
75+ , ServiceId
76+ , UserId
77+ , VendorId
78+ , WebhookId
79+ , WindowId
80+
81+ -- ** SubDomain
82+ , SubDomain
83+ , mkSubDomain
84+
85+ -- ** Address
86+ , Address
87+ , mkAddress
88+
89+ -- ** Miscellaneous
90+ , Empty (..)
91+ ) where
92+
93+import Network.PagerDuty.Internal.Types
stack.yamlnew file+7
@@ -0,0 +1,7 @@
1+resolver: lts-19.23
2+
3+packages:
4+- .
5+
6+nix:
7+ packages: [zlib]