-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The Github Repos API, as documented at
-- <http://developer.github.com/v3/repos/>
module GitHub.Endpoints.Repos (
    -- * Querying repositories
    currentUserRepos,
    currentUserReposR,
    userRepos,
    userRepos',
    userReposR,
    organizationRepos,
    organizationRepos',
    organizationReposR,
    repository,
    repository',
    repositoryR,
    contributors,
    contributors',
    contributorsR,
    contributorsWithAnonymous,
    contributorsWithAnonymous',
    languagesFor,
    languagesFor',
    languagesForR,
    tagsFor,
    tagsFor',
    tagsForR,
    branchesFor,
    branchesFor',
    branchesForR,

    -- ** Create
    createRepo',
    createRepoR,
    createOrganizationRepo',
    createOrganizationRepoR,
    forkExistingRepo',
    forkExistingRepoR,

    -- ** Edit
    editRepo,
    editRepoR,

    -- ** Delete
    deleteRepo,
    deleteRepoR,

    -- * Data
    module GitHub.Data,
    ) where

import GitHub.Data
import GitHub.Internal.Prelude
import GitHub.Request
import Prelude ()

repoPublicityQueryString :: RepoPublicity -> QueryString
repoPublicityQueryString :: RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicityAll     = [("type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "all")]
repoPublicityQueryString RepoPublicityOwner   = [("type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "owner")]
repoPublicityQueryString RepoPublicityMember  = [("type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "member")]
repoPublicityQueryString RepoPublicityPublic  = [("type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "public")]
repoPublicityQueryString RepoPublicityPrivate = [("type", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "private")]

-- | List your repositories.
currentUserRepos :: Auth -> RepoPublicity -> IO (Either Error (Vector Repo))
currentUserRepos :: Auth -> RepoPublicity -> IO (Either Error (Vector Repo))
currentUserRepos auth :: Auth
auth publicity :: RepoPublicity
publicity =
    Auth
-> GenRequest 'MtJSON Any (Vector Repo)
-> IO (Either Error (Vector Repo))
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON Any (Vector Repo)
 -> IO (Either Error (Vector Repo)))
-> GenRequest 'MtJSON Any (Vector Repo)
-> IO (Either Error (Vector Repo))
forall a b. (a -> b) -> a -> b
$ RepoPublicity -> FetchCount -> GenRequest 'MtJSON Any (Vector Repo)
forall (k :: RW).
RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR RepoPublicity
publicity FetchCount
FetchAll

-- | List your repositories.
-- See <https://developer.github.com/v3/repos/#list-your-repositories>
currentUserReposR :: RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR :: RepoPublicity -> FetchCount -> Request k (Vector Repo)
currentUserReposR publicity :: RepoPublicity
publicity =
    Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery  ["user", "repos"] QueryString
qs
  where
    qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity

-- | The repos for a user, by their login. Can be restricted to just repos they
-- own, are a member of, or publicize. Private repos will return empty list.
--
-- > userRepos "mike-burns" All
userRepos :: Name Owner -> RepoPublicity -> IO (Either Error (Vector Repo))
userRepos :: Name Owner -> RepoPublicity -> IO (Either Error (Vector Repo))
userRepos = Maybe Auth
-> Name Owner -> RepoPublicity -> IO (Either Error (Vector Repo))
userRepos' Maybe Auth
forall a. Maybe a
Nothing

-- | The repos for a user, by their login.
-- With authentication.
--
-- > userRepos' (Just $ BasicAuth "github-username" "github-password") "mike-burns" All
userRepos'
    :: Maybe Auth
    -> Name Owner
    -> RepoPublicity
    -> IO (Either Error (Vector Repo))
userRepos' :: Maybe Auth
-> Name Owner -> RepoPublicity -> IO (Either Error (Vector Repo))
userRepos' auth :: Maybe Auth
auth user :: Name Owner
user publicity :: RepoPublicity
publicity =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Repo)
-> IO (Either Error (Vector Repo))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Repo)
 -> IO (Either Error (Vector Repo)))
-> GenRequest 'MtJSON 'RO (Vector Repo)
-> IO (Either Error (Vector Repo))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> RepoPublicity
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Repo)
forall (k :: RW).
Name Owner
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
userReposR Name Owner
user RepoPublicity
publicity FetchCount
FetchAll

-- | List user repositories.
-- See <https://developer.github.com/v3/repos/#list-user-repositories>
userReposR :: Name Owner -> RepoPublicity -> FetchCount -> Request k(Vector Repo)
userReposR :: Name Owner
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
userReposR user :: Name Owner
user publicity :: RepoPublicity
publicity =
    Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery  ["users", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, "repos"] QueryString
qs
  where
    qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity

-- | The repos for an organization, by the organization name.
--
-- > organizationRepos "thoughtbot"
organizationRepos :: Name Organization -> IO (Either Error (Vector Repo))
organizationRepos :: Name Organization -> IO (Either Error (Vector Repo))
organizationRepos org :: Name Organization
org = Maybe Auth
-> Name Organization
-> RepoPublicity
-> IO (Either Error (Vector Repo))
organizationRepos' Maybe Auth
forall a. Maybe a
Nothing Name Organization
org RepoPublicity
RepoPublicityAll

-- | The repos for an organization, by the organization name.
-- With authentication.
--
-- > organizationRepos (Just $ BasicAuth "github-username" "github-password") "thoughtbot" All
organizationRepos'
    :: Maybe Auth
    -> Name Organization
    -> RepoPublicity
    -> IO (Either Error (Vector Repo))
organizationRepos' :: Maybe Auth
-> Name Organization
-> RepoPublicity
-> IO (Either Error (Vector Repo))
organizationRepos' auth :: Maybe Auth
auth org :: Name Organization
org publicity :: RepoPublicity
publicity =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Repo)
-> IO (Either Error (Vector Repo))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Repo)
 -> IO (Either Error (Vector Repo)))
-> GenRequest 'MtJSON 'RO (Vector Repo)
-> IO (Either Error (Vector Repo))
forall a b. (a -> b) -> a -> b
$ Name Organization
-> RepoPublicity
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Repo)
forall (k :: RW).
Name Organization
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
organizationReposR Name Organization
org RepoPublicity
publicity FetchCount
FetchAll

-- | List organization repositories.
-- See <https://developer.github.com/v3/repos/#list-organization-repositories>
organizationReposR
    :: Name Organization
    -> RepoPublicity
    -> FetchCount
    -> Request k (Vector Repo)
organizationReposR :: Name Organization
-> RepoPublicity -> FetchCount -> Request k (Vector Repo)
organizationReposR org :: Name Organization
org publicity :: RepoPublicity
publicity =
    Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, "repos"] QueryString
qs
  where
    qs :: QueryString
qs = RepoPublicity -> QueryString
repoPublicityQueryString RepoPublicity
publicity

-- | Details on a specific repo, given the owner and repo name.
--
-- > repository "mike-burns" "github"
repository :: Name Owner -> Name Repo -> IO (Either Error Repo)
repository :: Name Owner -> Name Repo -> IO (Either Error Repo)
repository = Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error Repo)
repository' Maybe Auth
forall a. Maybe a
Nothing

-- | Details on a specific repo, given the owner and repo name.
-- With authentication.
--
-- > repository' (Just $ BasicAuth "github-username" "github-password") "mike-burns" "github"
repository' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error Repo)
repository' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error Repo)
repository' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth -> GenRequest 'MtJSON 'RO Repo -> IO (Either Error Repo)
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO Repo -> IO (Either Error Repo))
-> GenRequest 'MtJSON 'RO Repo -> IO (Either Error Repo)
forall a b. (a -> b) -> a -> b
$ Name Owner -> Name Repo -> GenRequest 'MtJSON 'RO Repo
forall (k :: RW). Name Owner -> Name Repo -> Request k Repo
repositoryR Name Owner
user Name Repo
repo

-- | Query single repository.
-- See <https://developer.github.com/v3/repos/#get>
repositoryR :: Name Owner -> Name Repo -> Request k Repo
repositoryR :: Name Owner -> Name Repo -> Request k Repo
repositoryR user :: Name Owner
user repo :: Name Repo
repo =
    Paths -> QueryString -> Request k Repo
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query ["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] []

-- | Create a new repository.
--
-- > createRepo' (BasicAuth (user, password)) (newRepo "some_repo") {newRepoHasIssues = Just False}
createRepo' :: Auth -> NewRepo -> IO (Either Error Repo)
createRepo' :: Auth -> NewRepo -> IO (Either Error Repo)
createRepo' auth :: Auth
auth nrepo :: NewRepo
nrepo =
    Auth -> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo))
-> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall a b. (a -> b) -> a -> b
$ NewRepo -> GenRequest 'MtJSON 'RW Repo
createRepoR NewRepo
nrepo

-- | Create a new repository.
-- See <https://developer.github.com/v3/repos/#create>
createRepoR :: NewRepo -> Request 'RW Repo
createRepoR :: NewRepo -> GenRequest 'MtJSON 'RW Repo
createRepoR nrepo :: NewRepo
nrepo =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtJSON 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post ["user", "repos"] (NewRepo -> ByteString
forall a. ToJSON a => a -> ByteString
encode NewRepo
nrepo)

-- | Fork an existing repository.
forkExistingRepo' :: Auth -> Name Owner -> Name Repo -> Maybe (Name Owner) -> IO (Either Error Repo)
forkExistingRepo' :: Auth
-> Name Owner
-> Name Repo
-> Maybe (Name Owner)
-> IO (Either Error Repo)
forkExistingRepo' auth :: Auth
auth owner :: Name Owner
owner repo :: Name Repo
repo morg :: Maybe (Name Owner)
morg =
    Auth -> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo))
-> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo -> Maybe (Name Owner) -> GenRequest 'MtJSON 'RW Repo
forkExistingRepoR Name Owner
owner Name Repo
repo Maybe (Name Owner)
morg

-- | Fork an existing repository.
-- See <https://developer.github.com/v3/repos/forks/#create-a-fork>
-- TODO: The third paramater (an optional Organisation) is not used yet.
forkExistingRepoR :: Name Owner -> Name Repo -> Maybe (Name Owner) -> Request 'RW Repo
forkExistingRepoR :: Name Owner
-> Name Repo -> Maybe (Name Owner) -> GenRequest 'MtJSON 'RW Repo
forkExistingRepoR owner :: Name Owner
owner repo :: Name Repo
repo _morg :: Maybe (Name Owner)
_morg =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtJSON 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post ["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, "forks" ] ByteString
forall a. Monoid a => a
mempty

-- | Create a new repository for an organization.
--
-- > createOrganizationRepo (BasicAuth (user, password)) "thoughtbot" (newRepo "some_repo") {newRepoHasIssues = Just False}
createOrganizationRepo' :: Auth -> Name Organization -> NewRepo -> IO (Either Error Repo)
createOrganizationRepo' :: Auth -> Name Organization -> NewRepo -> IO (Either Error Repo)
createOrganizationRepo' auth :: Auth
auth org :: Name Organization
org nrepo :: NewRepo
nrepo =
    Auth -> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo))
-> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall a b. (a -> b) -> a -> b
$ Name Organization -> NewRepo -> GenRequest 'MtJSON 'RW Repo
createOrganizationRepoR Name Organization
org NewRepo
nrepo

-- | Create a new repository for an organization.
-- See <https://developer.github.com/v3/repos/#create>
createOrganizationRepoR :: Name Organization -> NewRepo -> Request 'RW Repo
createOrganizationRepoR :: Name Organization -> NewRepo -> GenRequest 'MtJSON 'RW Repo
createOrganizationRepoR org :: Name Organization
org nrepo :: NewRepo
nrepo =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtJSON 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post ["orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, "repos"] (NewRepo -> ByteString
forall a. ToJSON a => a -> ByteString
encode NewRepo
nrepo)

-- | Edit an existing repository.
--
-- > editRepo (BasicAuth (user, password)) "some_user" "some_repo" def {editDescription = Just "some description"}
editRepo
    :: Auth
    -> Name Owner      -- ^ owner
    -> Name Repo             -- ^ repository name
    -> EditRepo
    -> IO (Either Error Repo)
editRepo :: Auth
-> Name Owner -> Name Repo -> EditRepo -> IO (Either Error Repo)
editRepo auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo body :: EditRepo
body =
    Auth -> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo))
-> GenRequest 'MtJSON 'RW Repo -> IO (Either Error Repo)
forall a b. (a -> b) -> a -> b
$ Name Owner -> Name Repo -> EditRepo -> GenRequest 'MtJSON 'RW Repo
editRepoR Name Owner
user Name Repo
repo EditRepo
body


-- | Edit an existing repository.
-- See <https://developer.github.com/v3/repos/#edit>
editRepoR :: Name Owner -> Name Repo -> EditRepo -> Request 'RW Repo
editRepoR :: Name Owner -> Name Repo -> EditRepo -> GenRequest 'MtJSON 'RW Repo
editRepoR user :: Name Owner
user repo :: Name Repo
repo body :: EditRepo
body =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtJSON 'RW Repo
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Patch ["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
    -- if no name is given, use curent name
    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}

-- | The contributors to a repo, given the owner and repo name.
--
-- > contributors "thoughtbot" "paperclip"
contributors :: Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributors :: Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributors = Maybe Auth
-> Name Owner
-> Name Repo
-> IO (Either Error (Vector Contributor))
contributors' Maybe Auth
forall a. Maybe a
Nothing

-- | The contributors to a repo, given the owner and repo name.
-- With authentication.
--
-- > contributors' (Just $ BasicAuth "github-username" "github-password") "thoughtbot" "paperclip"
contributors' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributors' :: Maybe Auth
-> Name Owner
-> Name Repo
-> IO (Either Error (Vector Contributor))
contributors' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Contributor)
-> IO (Either Error (Vector Contributor))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Contributor)
 -> IO (Either Error (Vector Contributor)))
-> GenRequest 'MtJSON 'RO (Vector Contributor)
-> IO (Either Error (Vector Contributor))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Contributor)
forall (k :: RW).
Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR Name Owner
user Name Repo
repo Bool
False FetchCount
FetchAll

-- | List contributors.
-- See <https://developer.github.com/v3/repos/#list-contributors>
contributorsR
    :: Name Owner
    -> Name Repo
    -> Bool              -- ^ Include anonymous
    -> FetchCount
    -> Request k (Vector Contributor)
contributorsR :: Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR user :: Name Owner
user repo :: Name Repo
repo anon :: Bool
anon =
    Paths
-> QueryString -> FetchCount -> Request k (Vector Contributor)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["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, "contributors"] QueryString
qs
  where
    qs :: QueryString
qs | Bool
anon      = [("anon", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just "true")]
       | Bool
otherwise = []

-- | The contributors to a repo, including anonymous contributors (such as
-- deleted users or git commits with unknown email addresses), given the owner
-- and repo name.
--
-- > contributorsWithAnonymous "thoughtbot" "paperclip"
contributorsWithAnonymous :: Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributorsWithAnonymous :: Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributorsWithAnonymous = Maybe Auth
-> Name Owner
-> Name Repo
-> IO (Either Error (Vector Contributor))
contributorsWithAnonymous' Maybe Auth
forall a. Maybe a
Nothing

-- | The contributors to a repo, including anonymous contributors (such as
-- deleted users or git commits with unknown email addresses), given the owner
-- and repo name.
-- With authentication.
--
-- > contributorsWithAnonymous' (Just $ BasicAuth "github-username" "github-password") "thoughtbot" "paperclip"
contributorsWithAnonymous' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error (Vector Contributor))
contributorsWithAnonymous' :: Maybe Auth
-> Name Owner
-> Name Repo
-> IO (Either Error (Vector Contributor))
contributorsWithAnonymous' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Contributor)
-> IO (Either Error (Vector Contributor))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Contributor)
 -> IO (Either Error (Vector Contributor)))
-> GenRequest 'MtJSON 'RO (Vector Contributor)
-> IO (Either Error (Vector Contributor))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Contributor)
forall (k :: RW).
Name Owner
-> Name Repo
-> Bool
-> FetchCount
-> Request k (Vector Contributor)
contributorsR Name Owner
user Name Repo
repo Bool
True FetchCount
FetchAll

-- | The programming languages used in a repo along with the number of
-- characters written in that language. Takes the repo owner and name.
--
-- > languagesFor "mike-burns" "ohlaunch"
languagesFor :: Name Owner -> Name Repo -> IO (Either Error Languages)
languagesFor :: Name Owner -> Name Repo -> IO (Either Error Languages)
languagesFor = Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error Languages)
languagesFor' Maybe Auth
forall a. Maybe a
Nothing

-- | The programming languages used in a repo along with the number of
-- characters written in that language. Takes the repo owner and name.
-- With authentication.
--
-- > languagesFor' (Just $ BasicAuth "github-username" "github-password") "mike-burns" "ohlaunch"
languagesFor' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error Languages)
languagesFor' :: Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error Languages)
languagesFor' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth
-> GenRequest 'MtJSON 'RO Languages -> IO (Either Error Languages)
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO Languages -> IO (Either Error Languages))
-> GenRequest 'MtJSON 'RO Languages -> IO (Either Error Languages)
forall a b. (a -> b) -> a -> b
$ Name Owner -> Name Repo -> GenRequest 'MtJSON 'RO Languages
forall (k :: RW). Name Owner -> Name Repo -> Request k Languages
languagesForR Name Owner
user Name Repo
repo

-- | List languages.
-- See <https://developer.github.com/v3/repos/#list-languages>
languagesForR :: Name Owner -> Name Repo -> Request k Languages
languagesForR :: Name Owner -> Name Repo -> Request k Languages
languagesForR user :: Name Owner
user repo :: Name Repo
repo =
    Paths -> QueryString -> Request k Languages
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query ["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, "languages"] []

-- | The git tags on a repo, given the repo owner and name.
--
-- > tagsFor "thoughtbot" "paperclip"
tagsFor :: Name Owner -> Name Repo -> IO (Either Error (Vector Tag))
tagsFor :: Name Owner -> Name Repo -> IO (Either Error (Vector Tag))
tagsFor = Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Tag))
tagsFor' Maybe Auth
forall a. Maybe a
Nothing

-- | The git tags on a repo, given the repo owner and name.
-- With authentication.
--
-- > tagsFor' (Just $ BasicAuth "github-username" "github-password") "thoughtbot" "paperclip"
tagsFor' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error (Vector Tag))
tagsFor' :: Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Tag))
tagsFor' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Tag)
-> IO (Either Error (Vector Tag))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Tag)
 -> IO (Either Error (Vector Tag)))
-> GenRequest 'MtJSON 'RO (Vector Tag)
-> IO (Either Error (Vector Tag))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo -> FetchCount -> GenRequest 'MtJSON 'RO (Vector Tag)
forall (k :: RW).
Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR Name Owner
user Name Repo
repo FetchCount
FetchAll

-- | List tags.
-- See <https://developer.github.com/v3/repos/#list-tags>
tagsForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Tag)
tagsForR user :: Name Owner
user repo :: Name Repo
repo =
    Paths -> QueryString -> FetchCount -> Request k (Vector Tag)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery  ["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, "tags"] []

-- | The git branches on a repo, given the repo owner and name.
--
-- > branchesFor "thoughtbot" "paperclip"
branchesFor :: Name Owner -> Name Repo -> IO (Either Error (Vector Branch))
branchesFor :: Name Owner -> Name Repo -> IO (Either Error (Vector Branch))
branchesFor = Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Branch))
branchesFor' Maybe Auth
forall a. Maybe a
Nothing

-- | The git branches on a repo, given the repo owner and name.
-- With authentication.
--
-- > branchesFor' (Just $ BasicAuth "github-username" "github-password") "thoughtbot" "paperclip"
branchesFor' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error (Vector Branch))
branchesFor' :: Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Branch))
branchesFor' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector Branch)
-> IO (Either Error (Vector Branch))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector Branch)
 -> IO (Either Error (Vector Branch)))
-> GenRequest 'MtJSON 'RO (Vector Branch)
-> IO (Either Error (Vector Branch))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Branch)
forall (k :: RW).
Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR Name Owner
user Name Repo
repo FetchCount
FetchAll

-- | List branches.
-- See <https://developer.github.com/v3/repos/#list-branches>
branchesForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Branch)
branchesForR user :: Name Owner
user repo :: Name Repo
repo =
    Paths -> QueryString -> FetchCount -> Request k (Vector Branch)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery  ["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, "branches"] []

-- | Delete an existing repository.
--
-- > deleteRepo (BasicAuth (user, password)) "thoughtbot" "some_repo"
deleteRepo :: Auth -> Name Owner -> Name Repo -> IO (Either Error ())
deleteRepo :: Auth -> Name Owner -> Name Repo -> IO (Either Error ())
deleteRepo auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    Auth -> GenRequest 'MtUnit 'RW () -> IO (Either Error ())
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtUnit 'RW () -> IO (Either Error ()))
-> GenRequest 'MtUnit 'RW () -> IO (Either Error ())
forall a b. (a -> b) -> a -> b
$ Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR Name Owner
user Name Repo
repo

-- | Delete a repository,.
-- See <https://developer.github.com/v3/repos/#delete-a-repository>
deleteRepoR :: Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR :: Name Owner -> Name Repo -> GenRequest 'MtUnit 'RW ()
deleteRepoR user :: Name Owner
user repo :: Name Repo
repo =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType *) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete ["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