{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Branches where
import Data.Either
import qualified Data.Text as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Types.Status
branches :: Project -> GitLab [Branch]
branches :: Project -> GitLab [Branch]
branches Project
project = do
Either Status [Branch]
result <- Int -> GitLab (Either Status [Branch])
branches' (Project -> Int
project_id Project
project)
[Branch] -> GitLab [Branch]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Branch] -> Either Status [Branch] -> [Branch]
forall b a. b -> Either a b -> b
fromRight ([Char] -> [Branch]
forall a. HasCallStack => [Char] -> a
error [Char]
"branches error") Either Status [Branch]
result)
branches' :: Int -> GitLab (Either Status [Branch])
branches' :: Int -> GitLab (Either Status [Branch])
branches' Int
projectId =
Text -> GitLab (Either Status [Branch])
forall a. FromJSON a => Text -> GitLab (Either Status [a])
gitlab Text
addr
where
addr :: Text
addr =
Text
"/projects/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
projectId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/repository"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/branches"