git.iko.soy/typeable/pagerduty
on develop help sign in
Adding NotificationRules REST API
commitb43873cc80666a6e2fa75045fcbd7585779d04f5 authorBrendan Hay <brendan.g.hay@gmail.com> dateTue 14 Oct 2014, 16:55 (12 years ago) parente35cc26
4 files changed+113−11
Makefile+3 pagerduty.cabal+9−9 src/Network/PagerDuty/REST/Users/ContactMethods.hs+67−2 src/Network/PagerDuty/REST/Users/NotificationRules.hs+34
Makefile+3
@@ -3,6 +3,9 @@ FLAGS := -j --disable-documentation --disable-library-coverage
33build:
44 cabal build $(addprefix -,$(findstring j,$(MAKEFLAGS)))
55
6+all:
7+ make clean; make install && make build
8+
69install: cabal.sandbox.config
710 cabal install $(FLAGS) --only-dependencies
811
pagerduty.cabal+9−9
@@ -59,26 +59,26 @@ library
5959 , Network.PagerDuty.Types
6060
6161 build-depends:
62− aeson > 0.7 && <= 8.0
62+ aeson > 0.7 && <= 0.8
6363 , base >= 4.5 && < 5.0
6464-- , base64-bytestring >= 1.0 && < 1.1
6565 , bifunctors
6666
67− , bytestring >= 0.9 && < 1.0
67+ , bytestring >= 0.9
6868 , bytestring-conversion >= 0.2.1
6969 , conduit >= 0.5.5
70− , data-default >= 0.5
70+ , data-default-class
7171 , exceptions >= 0.6
72− , http-client >= 0.3.6 && < 0.5
73− , http-types >= 0.8 && < 1.0
74− , lens >= 4.0 && < 5.0
72+ , http-client >= 0.3.6
73+ , http-types >= 0.8
74+ , lens >= 4.0
7575 , lens-aeson >= 1.0
7676 , mmorph >= 1.0
77− , mtl >= 2.2.1 && < 3.0
77+ , mtl >= 2.2.1
7878 , old-locale
79− , text >= 1.1 && < 2.0
79+ , text >= 1.1
8080 , time == 1.4.*
81− , transformers >= 0.4.1 && < 0.5
81+ , transformers >= 0.4.1
8282 , unordered-containers >= 0.2.3
8383
8484 , generics-sop
src/Network/PagerDuty/REST/Users/ContactMethods.hs+67−2
@@ -30,6 +30,71 @@ import Network.HTTP.Types
3030import Network.PagerDuty.TH
3131import Network.PagerDuty.Types
3232
33−users :: Path
34−users = "users"
33+contacts :: UserId -> Path
34+contacts u = "users" % u % "contact_methods"
3535
36+data Contact = Contact
37+ { _cId :: ContactId
38+ , _cUserId :: UserId
39+ , _cLabel :: Text
40+ , _cAddress :: Address
41+ , _cType :: ContactType
42+ , _cSendShortEmail :: Maybe Bool'
43+ , _cBlacklisted :: Maybe Bool'
44+ } deriving (Eq, Show)
45+
46+data ContactType
47+ = SMS
48+ | Phone
49+ | Email
50+ deriving (Eq, Show)
51+
52+deriveNullary ''ContactType
53+
54+Name Type Required Description
55+type String Yes The type of the contact method. One of SMS, email or phone.
56+address String Yes The id of the contact method. For SMS and phone it is the number, and for email it is the email address.
57+country_code Integer No The number code for your country. Not used for email. Defaults to 1.
58+label String No A human friendly label for the contact method. (ie: "Home Phone", "Work Email", etc.) Defaults to the type of the contact method and the address (with country code for phone numbers).
59+send_short_email Boolean No Send an abbreviated email message instead of the standard email output. Useful for email-to-SMS gateways and email based pagers. Only valid for email contact methods. Defaults to false.
60+
61+
62+-- | List existing contact methods for the specified user.
63+--
64+-- @GET \/users\/\:user_id\/contact_methods@
65+--
66+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/contact_methods/list>
67+listContacts
68+
69+-- | Get details for a contact method.
70+--
71+-- @GET \/users\/\:user_id\/contact_methods\/\:id@
72+--
73+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/contact_methods/show>
74+getContact
75+
76+-- | Create a new contact method for a given user. A contact method can be one
77+-- of the following types: SMS, email, and phone. push_notification contact
78+-- methods cannot be created using this API, they are added automatically during
79+-- device registration.
80+--
81+-- @POST \/users\/\:user_id\/contact_methods@
82+--
83+-- /Note:/ The contact info must be unique.
84+--
85+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/contact_methods/create>
86+createContact
87+
88+-- | Update an existing contact method of a given user. Note that you cannot change the type of an existing method.
89+--
90+-- @PUT \/users\/\:user_id\/contact_methods\/\:id@
91+--
92+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/contact_methods/update>
93+updateContact
94+
95+-- | Remove a contact method and any corresponding notification rules.
96+--
97+-- @DELETE \/users\/\:user_id\/contact_methods\/\:id@
98+--
99+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/contact_methods/delete>
100+deleteContact
src/Network/PagerDuty/REST/Users/NotificationRules.hs+34
@@ -33,3 +33,37 @@ import Network.PagerDuty.Types
3333users :: Path
3434users = "users"
3535
36+-- | List existing notification rules for the specified user.
37+--
38+-- @GET \/users\/\:user_id\/notification_rules@
39+--
40+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/list>
41+listNotificationRules
42+
43+-- | Get details for a notification rule.
44+--
45+-- @GET \/users\/\:user_id\/notification_rules\/\:id@
46+--
47+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/show>
48+getNotificationRule
49+
50+-- | Create a new notification rule for the specified user.
51+--
52+-- @POST \/users\/\:user_id\/notification_rules@
53+--
54+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/create>
55+createNotificationRule
56+
57+-- | Update an existing notification rule.
58+--
59+-- @PUT \/users\/\:user_id\/notification_rules\/\:id@
60+--
61+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/update>
62+updateNotificationRule
63+
64+-- | Remove a notification rule.
65+--
66+-- @DELETE \/users\/\:user_id\/notification_rules\/\:id@
67+--
68+-- /See:/ <http://developer.pagerduty.com/documentation/rest/users/notification_rules/delete>
69+deleteNotificationRule