-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- Hot forking action, as described at
-- <http://developer.github.com/v3/repos/forks/>.
module GitHub.Endpoints.Repos.Forks (
    forksFor,
    forksFor',
    forksForR,
    module GitHub.Data,
    ) where

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

-- | All the repos that are forked off the given repo.
--
-- > forksFor "thoughtbot" "paperclip"
forksFor :: Name Owner -> Name Repo -> IO (Either Error  (Vector Repo))
forksFor :: Name Owner -> Name Repo -> IO (Either Error (Vector Repo))
forksFor = Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Repo))
forksFor' Maybe Auth
forall a. Maybe a
Nothing

-- | All the repos that are forked off the given repo.
-- | With authentication
--
-- > forksFor' (Just $ BasicAuth "github-username" "github-password") "thoughtbot" "paperclip"
forksFor' :: Maybe Auth -> Name Owner -> Name Repo -> IO (Either Error  (Vector Repo))
forksFor' :: Maybe Auth
-> Name Owner -> Name Repo -> IO (Either Error (Vector Repo))
forksFor' auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo =
    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
-> Name Repo -> FetchCount -> GenRequest 'MtJSON 'RO (Vector Repo)
forall (k :: RW).
Name Owner -> Name Repo -> FetchCount -> Request k (Vector Repo)
forksForR Name Owner
user Name Repo
repo FetchCount
FetchAll

-- | List forks.
-- See <https://developer.github.com/v3/repos/forks/#list-forks>
forksForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Repo)
forksForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Repo)
forksForR user :: Name Owner
user repo :: Name Repo
repo =
    Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
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, "forks"] []