Skip to content

Commit cfe6b07

Browse files
authored
Merge pull request #152 from davidanthoff/deploykeys
Add support for deploy keys
2 parents 3b28dfd + 72ca3d3 commit cfe6b07

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/GitHub.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ include("repositories/commits.jl")
8989
include("repositories/branches.jl")
9090
include("repositories/statuses.jl")
9191
include("repositories/webhooks.jl")
92+
include("repositories/deploykeys.jl")
9293

9394
# export -------
9495

@@ -134,6 +135,13 @@ export # webhooks.jl
134135
Webhook,
135136
create_webhook
136137

138+
export # deploykeys.jl
139+
DeployKey,
140+
deploykey,
141+
deploykeys,
142+
create_deploykey,
143+
delete_deploykey
144+
137145
##########
138146
# Issues #
139147
##########

src/repositories/deploykeys.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
mutable struct DeployKey <: GitHubType
2+
id::Union{Int, Nothing}
3+
key::Union{String, Nothing}
4+
url::Union{HTTP.URI, Nothing}
5+
title::Union{String, Nothing}
6+
verified::Union{Bool, Nothing}
7+
created_at::Union{Dates.DateTime, Nothing}
8+
read_only::Union{Bool, Nothing}
9+
end
10+
11+
DeployKey(data::Dict) = json2github(DeployKey, data)
12+
13+
namefield(key::DeployKey) = key.id
14+
15+
@api_default function deploykey(api::GitHubAPI, repo, deploykey_obj; options...)
16+
result = gh_get_json(api, "/repos/$(name(repo))/keys/$(name(deploykey_obj))"; options...)
17+
return DeployKey(result)
18+
end
19+
20+
@api_default function deploykeys(api::GitHubAPI, repo; options...)
21+
results, page_data = gh_get_paged_json(api, "/repos/$(name(repo))/keys"; options...)
22+
return map(DeployKey, results), page_data
23+
end
24+
25+
@api_default function create_deploykey(api::GitHubAPI, repo; options...)
26+
result = gh_post_json(api, "/repos/$(name(repo))/keys"; options...)
27+
return DeployKey(result)
28+
end
29+
30+
@api_default function delete_deploykey(api::GitHubAPI, repo, item; options...)
31+
return gh_delete(api, "/repos/$(name(repo))/keys/$(name(item))"; options...)
32+
end

0 commit comments

Comments
 (0)