module GitHub.Endpoints.Repos (
currentUserReposR,
userReposR,
organizationReposR,
repositoryR,
contributorsR,
languagesForR,
tagsForR,
branchesForR,
createRepoR,
createOrganizationRepoR,
forkExistingRepoR,
editRepoR,
deleteRepoR,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()
repoPublicityQueryString :: RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicityAll = [("type", Just "all")]
repoPublicityQueryString RepoPublicityOwner = [("type", Just "owner")]
repoPublicityQueryString RepoPublicityMember = [("type", Just "member")]
repoPublicityQueryString RepoPublicityPublic = [("type", Just "public")]
repoPublicityQueryString RepoPublicityPrivate = [("type", Just "private")]
currentUserReposR :: RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR publicity =
pagedQuery ["user", "repos"] qs
where
qs = repoPublicityQueryString publicity
userReposR :: Name Owner -> RepoPublicity -> FetchCount -> Request k(Vector Repo)
userReposR user publicity =
pagedQuery ["users", toPathPart user, "repos"] qs
where
qs = repoPublicityQueryString publicity
organizationReposR
:: Name Organization
-> RepoPublicity
-> FetchCount
-> Request k (Vector Repo)
organizationReposR org publicity =
pagedQuery ["orgs", toPathPart org, "repos"] qs
where
qs = repoPublicityQueryString publicity
repositoryR :: Name Owner -> Name Repo -> Request k Repo
repositoryR user repo =
query ["repos", toPathPart user, toPathPart repo] []
createRepoR :: NewRepo -> Request 'RW Repo
createRepoR nrepo =
command Post ["user", "repos"] (encode nrepo)
forkExistingRepoR :: Name Owner -> Name Repo -> Maybe (Name Owner) -> Request 'RW Repo
forkExistingRepoR owner repo _morg =
command Post ["repos", toPathPart owner, toPathPart repo, "forks" ] mempty
createOrganizationRepoR :: Name Organization -> NewRepo -> Request 'RW Repo
createOrganizationRepoR org nrepo =
command Post ["orgs", toPathPart org, "repos"] (encode nrepo)
editRepoR :: Name Owner -> Name Repo -> EditRepo -> Request 'RW Repo
editRepoR user repo body =
command Patch ["repos", toPathPart user, toPathPart repo] (encode b)
where
b = body {editName = editName body <|> Just repo}
contributorsR
:: Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR user repo anon =
pagedQuery ["repos", toPathPart user, toPathPart repo, "contributors"] qs
where
qs | anon = [("anon", Just "true")]
| otherwise = []
languagesForR :: Name Owner -> Name Repo -> Request k Languages
languagesForR user repo =
query ["repos", toPathPart user, toPathPart repo, "languages"] []
tagsForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR user repo =
pagedQuery ["repos", toPathPart user, toPathPart repo, "tags"] []
branchesForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR user repo =
pagedQuery ["repos", toPathPart user, toPathPart repo, "branches"] []
deleteRepoR :: Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR user repo =
Command Delete ["repos", toPathPart user, toPathPart repo] mempty