-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathreference.jl
32 lines (25 loc) · 1.14 KB
/
reference.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@ghdef mutable struct Reference
ref::Union{String, Nothing}
url::Union{URIs.URI, Nothing}
object::Union{Dict, Nothing}
end
name(ref::Reference) = String(split(ref.ref, "refs/")[2])
@api_default function reference(api::GitHubAPI, repo, ref_obj; options...)
result = gh_get_json(api, "/repos/$(name(repo))/git/refs/$(name(ref_obj))"; options...)
return Reference(result)
end
@api_default function references(api::GitHubAPI, repo; options...)
results, page_data = gh_get_paged_json(api, "/repos/$(name(repo))/git/refs"; options...)
return Reference.(results), page_data
end
@api_default function create_reference(api::GitHubAPI, repo; options...)
result = gh_post_json(api, "/repos/$(name(repo))/git/refs"; options...)
return Reference(result)
end
@api_default function update_reference(api::GitHubAPI, repo, ref_obj; options...)
result = gh_patch_json(api, "/repos/$(name(repo))/git/refs/$(name(ref_obj))"; options...)
return Reference(result)
end
@api_default function delete_reference(api::GitHubAPI, repo, ref_obj; options...)
return gh_delete(api, "/repos/$(name(repo))/git/refs/$(name(ref_obj))"; options...)
end