Skip to content

Commit 85b9970

Browse files
committed
Add API wrapper functions for creating/deleting deploy keys
1 parent 1282590 commit 85b9970

5 files changed

Lines changed: 136 additions & 83 deletions

File tree

github.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Library
8383
GitHub.Data.Teams
8484
GitHub.Data.Activities
8585
GitHub.Data.URL
86+
GitHub.Data.DeployKeys
8687
GitHub.Data.Webhooks
8788
GitHub.Data.Webhooks.Validate
8889
GitHub.Endpoints.Activity.Starring
@@ -109,6 +110,7 @@ Library
109110
GitHub.Endpoints.Repos.Commits
110111
GitHub.Endpoints.Repos.Forks
111112
GitHub.Endpoints.Repos.Webhooks
113+
GitHub.Endpoints.Repos.DeployKeys
112114
GitHub.Endpoints.Search
113115
GitHub.Endpoints.Users
114116
GitHub.Endpoints.Users.Followers

samples/github-samples.cabal

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- This file has been generated from package.yaml by hpack version 0.13.0.
1+
-- This file has been generated from package.yaml by hpack version 0.9.0.
22
--
33
-- see: https://github.com/sol/hpack
44

@@ -20,10 +20,10 @@ library
2020
Common
2121
default-language: Haskell2010
2222

23-
executable github-add-team-membership-for
24-
main-is: AddTeamMembershipFor.hs
23+
executable github-edit-team
24+
main-is: EditTeam.hs
2525
hs-source-dirs:
26-
Teams/Memberships
26+
Teams
2727
ghc-options: -Wall
2828
build-depends:
2929
base
@@ -32,12 +32,17 @@ executable github-add-team-membership-for
3232
, text
3333
, github-samples
3434
other-modules:
35-
DeleteTeamMembershipFor
36-
TeamMembershipInfoFor
35+
DeleteTeam
36+
ListRepos
37+
ListTeamsCurrent
38+
Memberships.AddTeamMembershipFor
39+
Memberships.DeleteTeamMembershipFor
40+
Memberships.TeamMembershipInfoFor
41+
TeamInfoFor
3742
default-language: Haskell2010
3843

39-
executable github-delete-team
40-
main-is: DeleteTeam.hs
44+
executable github-list-team-current
45+
main-is: ListTeamsCurrent.hs
4146
hs-source-dirs:
4247
Teams
4348
ghc-options: -Wall
@@ -48,33 +53,35 @@ executable github-delete-team
4853
, text
4954
, github-samples
5055
other-modules:
56+
DeleteTeam
5157
EditTeam
5258
ListRepos
53-
ListTeamsCurrent
5459
Memberships.AddTeamMembershipFor
5560
Memberships.DeleteTeamMembershipFor
5661
Memberships.TeamMembershipInfoFor
5762
TeamInfoFor
5863
default-language: Haskell2010
5964

60-
executable github-delete-team-membership-for
61-
main-is: DeleteTeamMembershipFor.hs
65+
executable github-operational
66+
main-is: Operational.hs
6267
hs-source-dirs:
63-
Teams/Memberships
68+
Operational
6469
ghc-options: -Wall
6570
build-depends:
6671
base
6772
, base-compat
6873
, github
6974
, text
7075
, github-samples
71-
other-modules:
72-
AddTeamMembershipFor
73-
TeamMembershipInfoFor
76+
, http-client
77+
, http-client-tls
78+
, operational
79+
, transformers
80+
, transformers-compat
7481
default-language: Haskell2010
7582

76-
executable github-edit-team
77-
main-is: EditTeam.hs
83+
executable github-list-team-repos
84+
main-is: ListRepos.hs
7885
hs-source-dirs:
7986
Teams
8087
ghc-options: -Wall
@@ -86,18 +93,18 @@ executable github-edit-team
8693
, github-samples
8794
other-modules:
8895
DeleteTeam
89-
ListRepos
96+
EditTeam
9097
ListTeamsCurrent
9198
Memberships.AddTeamMembershipFor
9299
Memberships.DeleteTeamMembershipFor
93100
Memberships.TeamMembershipInfoFor
94101
TeamInfoFor
95102
default-language: Haskell2010
96103

97-
executable github-list-followers
98-
main-is: ListFollowers.hs
104+
executable github-delete-team
105+
main-is: DeleteTeam.hs
99106
hs-source-dirs:
100-
Users/Followers
107+
Teams
101108
ghc-options: -Wall
102109
build-depends:
103110
base
@@ -106,29 +113,35 @@ executable github-list-followers
106113
, text
107114
, github-samples
108115
other-modules:
109-
Example
110-
ListFollowing
116+
EditTeam
117+
ListRepos
118+
ListTeamsCurrent
119+
Memberships.AddTeamMembershipFor
120+
Memberships.DeleteTeamMembershipFor
121+
Memberships.TeamMembershipInfoFor
122+
TeamInfoFor
111123
default-language: Haskell2010
112124

113-
executable github-list-followers-example
114-
main-is: Example.hs
125+
executable github-delete-team-membership-for
126+
main-is: DeleteTeamMembershipFor.hs
115127
hs-source-dirs:
116-
Users/Followers
128+
Teams/Memberships
117129
ghc-options: -Wall
118130
build-depends:
119131
base
120132
, base-compat
121133
, github
122134
, text
135+
, github-samples
123136
other-modules:
124-
ListFollowers
125-
ListFollowing
137+
AddTeamMembershipFor
138+
TeamMembershipInfoFor
126139
default-language: Haskell2010
127140

128-
executable github-list-following
129-
main-is: ListFollowing.hs
141+
executable github-show-user-2
142+
main-is: ShowUser2.hs
130143
hs-source-dirs:
131-
Users/Followers
144+
Users
132145
ghc-options: -Wall
133146
build-depends:
134147
base
@@ -137,14 +150,16 @@ executable github-list-following
137150
, text
138151
, github-samples
139152
other-modules:
140-
Example
141-
ListFollowers
153+
Followers.Example
154+
Followers.ListFollowers
155+
Followers.ListFollowing
156+
ShowUser
142157
default-language: Haskell2010
143158

144-
executable github-list-team-current
145-
main-is: ListTeamsCurrent.hs
159+
executable github-show-user
160+
main-is: ShowUser.hs
146161
hs-source-dirs:
147-
Teams
162+
Users
148163
ghc-options: -Wall
149164
build-depends:
150165
base
@@ -153,19 +168,16 @@ executable github-list-team-current
153168
, text
154169
, github-samples
155170
other-modules:
156-
DeleteTeam
157-
EditTeam
158-
ListRepos
159-
Memberships.AddTeamMembershipFor
160-
Memberships.DeleteTeamMembershipFor
161-
Memberships.TeamMembershipInfoFor
162-
TeamInfoFor
171+
Followers.Example
172+
Followers.ListFollowers
173+
Followers.ListFollowing
174+
ShowUser2
163175
default-language: Haskell2010
164176

165-
executable github-list-team-repos
166-
main-is: ListRepos.hs
177+
executable github-list-following
178+
main-is: ListFollowing.hs
167179
hs-source-dirs:
168-
Teams
180+
Users/Followers
169181
ghc-options: -Wall
170182
build-depends:
171183
base
@@ -174,37 +186,29 @@ executable github-list-team-repos
174186
, text
175187
, github-samples
176188
other-modules:
177-
DeleteTeam
178-
EditTeam
179-
ListTeamsCurrent
180-
Memberships.AddTeamMembershipFor
181-
Memberships.DeleteTeamMembershipFor
182-
Memberships.TeamMembershipInfoFor
183-
TeamInfoFor
189+
Example
190+
ListFollowers
184191
default-language: Haskell2010
185192

186-
executable github-operational
187-
main-is: Operational.hs
193+
executable github-list-followers-example
194+
main-is: Example.hs
188195
hs-source-dirs:
189-
Operational
196+
Users/Followers
190197
ghc-options: -Wall
191198
build-depends:
192199
base
193200
, base-compat
194201
, github
195202
, text
196-
, github-samples
197-
, http-client
198-
, http-client-tls
199-
, operational
200-
, transformers
201-
, transformers-compat
203+
other-modules:
204+
ListFollowers
205+
ListFollowing
202206
default-language: Haskell2010
203207

204-
executable github-show-user
205-
main-is: ShowUser.hs
208+
executable github-add-team-membership-for
209+
main-is: AddTeamMembershipFor.hs
206210
hs-source-dirs:
207-
Users
211+
Teams/Memberships
208212
ghc-options: -Wall
209213
build-depends:
210214
base
@@ -213,16 +217,14 @@ executable github-show-user
213217
, text
214218
, github-samples
215219
other-modules:
216-
Followers.Example
217-
Followers.ListFollowers
218-
Followers.ListFollowing
219-
ShowUser2
220+
DeleteTeamMembershipFor
221+
TeamMembershipInfoFor
220222
default-language: Haskell2010
221223

222-
executable github-show-user-2
223-
main-is: ShowUser2.hs
224+
executable github-team-membership-info-for
225+
main-is: TeamMembershipInfoFor.hs
224226
hs-source-dirs:
225-
Users
227+
Teams/Memberships
226228
ghc-options: -Wall
227229
build-depends:
228230
base
@@ -231,16 +233,14 @@ executable github-show-user-2
231233
, text
232234
, github-samples
233235
other-modules:
234-
Followers.Example
235-
Followers.ListFollowers
236-
Followers.ListFollowing
237-
ShowUser
236+
AddTeamMembershipFor
237+
DeleteTeamMembershipFor
238238
default-language: Haskell2010
239239

240-
executable github-team-membership-info-for
241-
main-is: TeamMembershipInfoFor.hs
240+
executable github-list-followers
241+
main-is: ListFollowers.hs
242242
hs-source-dirs:
243-
Teams/Memberships
243+
Users/Followers
244244
ghc-options: -Wall
245245
build-depends:
246246
base
@@ -249,8 +249,8 @@ executable github-team-membership-info-for
249249
, text
250250
, github-samples
251251
other-modules:
252-
AddTeamMembershipFor
253-
DeleteTeamMembershipFor
252+
Example
253+
ListFollowing
254254
default-language: Haskell2010
255255

256256
executable github-teaminfo-for

src/GitHub/Data.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module GitHub.Data (
3535
module GitHub.Data.Comments,
3636
module GitHub.Data.Content,
3737
module GitHub.Data.Definitions,
38+
module GitHub.Data.DeployKeys,
3839
module GitHub.Data.Gists,
3940
module GitHub.Data.GitData,
4041
module GitHub.Data.Issues,
@@ -44,7 +45,7 @@ module GitHub.Data (
4445
module GitHub.Data.Search,
4546
module GitHub.Data.Teams,
4647
module GitHub.Data.URL,
47-
module GitHub.Data.Webhooks,
48+
module GitHub.Data.Webhooks
4849
) where
4950

5051
import GitHub.Internal.Prelude
@@ -54,6 +55,7 @@ import GitHub.Data.Activities
5455
import GitHub.Data.Comments
5556
import GitHub.Data.Content
5657
import GitHub.Data.Definitions
58+
import GitHub.Data.DeployKeys
5759
import GitHub.Data.Gists
5860
import GitHub.Data.GitData
5961
import GitHub.Data.Id

src/GitHub/Data/DeployKeys.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ instance FromJSON RepoDeployKey where
2828
<*> o .: "verified"
2929
<*> o .: "created_at"
3030
<*> o .: "read_only"
31+
32+
data NewRepoDeployKey = NewRepoDeployKey {
33+
newRepoDeployKeyKey :: !Text
34+
,newRepoDeployKeyTitle :: !Text
35+
,newRepoDeployKeyReadOnly :: !Bool
36+
} deriving (Show, Data, Typeable, Eq, Ord, Generic)
37+
38+
instance ToJSON NewRepoDeployKey where
39+
toJSON (NewRepoDeployKey key title readOnly) =
40+
object [
41+
"key" .= key
42+
, "title" .= title
43+
, "read_only" .= readOnly
44+
]
45+
46+
instance FromJSON NewRepoDeployKey where
47+
parseJSON = withObject "RepoDeployKey" $ \o ->
48+
NewRepoDeployKey <$> o .: "key"
49+
<*> o .: "title"
50+
<*> o .: "read_only"

0 commit comments

Comments
 (0)