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 :: RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
RepoPublicityAll = [(ByteString
"type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"all")]
repoPublicityQueryString RepoPublicity
RepoPublicityOwner = [(ByteString
"type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"owner")]
repoPublicityQueryString RepoPublicity
RepoPublicityMember = [(ByteString
"type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"member")]
repoPublicityQueryString RepoPublicity
RepoPublicityPublic = [(ByteString
"type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"public")]
repoPublicityQueryString RepoPublicity
RepoPublicityPrivate = [(ByteString
"type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"private")]
currentUserReposR :: RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR :: forall (k :: RW).
RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR RepoPublicity
publicity =
Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"user", Text
"repos"] QueryString
qs
where
qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity
userReposR :: Name Owner -> RepoPublicity -> FetchCount -> Request k(Vector Repo)
userReposR :: forall (k :: RW).
Name Owner
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
userReposR Name Owner
user RepoPublicity
publicity =
Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"users", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Text
"repos"] QueryString
qs
where
qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity
organizationReposR
:: Name Organization
-> RepoPublicity
-> FetchCount
-> Request k (Vector Repo)
organizationReposR :: forall (k :: RW).
Name Organization
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
organizationReposR Name Organization
org RepoPublicity
publicity =
Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"repos"] QueryString
qs
where
qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity
repositoryR :: Name Owner -> Name Repo -> Request k Repo
repositoryR :: forall (k :: RW). Name Owner -> Name Repo -> Request k Repo
repositoryR Name Owner
user Name Repo
repo =
Paths -> QueryString -> Request k Repo
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo] []
createRepoR :: NewRepo -> Request 'RW Repo
createRepoR :: NewRepo -> Request 'RW Repo
createRepoR NewRepo
nrepo =
CommandMethod -> Paths -> ByteString -> Request 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post [Text
"user", Text
"repos"] (NewRepo -> ByteString
forall a. ToJSON a => a -> ByteString
encode NewRepo
nrepo)
forkExistingRepoR :: Name Owner -> Name Repo -> Maybe (Name Owner) -> Request 'RW Repo
forkExistingRepoR :: Name Owner -> Name Repo -> Maybe (Name Owner) -> Request 'RW Repo
forkExistingRepoR Name Owner
owner Name Repo
repo Maybe (Name Owner)
_morg =
CommandMethod -> Paths -> ByteString -> Request 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
owner, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"forks" ] ByteString
forall a. Monoid a => a
mempty
createOrganizationRepoR :: Name Organization -> NewRepo -> Request 'RW Repo
createOrganizationRepoR :: Name Organization -> NewRepo -> Request 'RW Repo
createOrganizationRepoR Name Organization
org NewRepo
nrepo =
CommandMethod -> Paths -> ByteString -> Request 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"repos"] (NewRepo -> ByteString
forall a. ToJSON a => a -> ByteString
encode NewRepo
nrepo)
editRepoR :: Name Owner -> Name Repo -> EditRepo -> Request 'RW Repo
editRepoR :: Name Owner -> Name Repo -> EditRepo -> Request 'RW Repo
editRepoR Name Owner
user Name Repo
repo EditRepo
body =
CommandMethod -> Paths -> ByteString -> Request 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Patch [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo] (EditRepo -> ByteString
forall a. ToJSON a => a -> ByteString
encode EditRepo
b)
where
b :: EditRepo
b = EditRepo
body {editName :: Maybe (Name Repo)
editName = EditRepo -> Maybe (Name Repo)
editName EditRepo
body Maybe (Name Repo) -> Maybe (Name Repo) -> Maybe (Name Repo)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Name Repo -> Maybe (Name Repo)
forall a. a -> Maybe a
Just Name Repo
repo}
contributorsR
:: Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR :: forall (k :: RW).
Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR Name Owner
user Name Repo
repo Bool
anon =
Paths
-> QueryString -> FetchCount -> Request k (Vector Contributor)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"contributors"] QueryString
qs
where
qs :: QueryString
qs | Bool
anon = [(ByteString
"anon", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"true")]
| Bool
otherwise = []
languagesForR :: Name Owner -> Name Repo -> Request k Languages
languagesForR :: forall (k :: RW). Name Owner -> Name Repo -> Request k Languages
languagesForR Name Owner
user Name Repo
repo =
Paths -> QueryString -> Request k Languages
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"languages"] []
tagsForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR :: forall (k :: RW).
Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR Name Owner
user Name Repo
repo =
Paths -> QueryString -> FetchCount -> Request k (Vector Tag)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"tags"] []
branchesForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR :: forall (k :: RW).
Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR Name Owner
user Name Repo
repo =
Paths -> QueryString -> FetchCount -> Request k (Vector Branch)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"branches"] []
deleteRepoR :: Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR :: Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR Name Owner
user Name Repo
repo =
CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo] ByteString
forall a. Monoid a => a
mempty