{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Jobs where
import Data.Either
import qualified Data.Text as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Types.Status
jobs ::
Project ->
GitLab [Job]
jobs :: Project -> GitLab [Job]
jobs Project
project = do
Either Status [Job]
result <- Int -> GitLab (Either Status [Job])
jobs' (Project -> Int
project_id Project
project)
[Job] -> GitLab [Job]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Job] -> Either Status [Job] -> [Job]
forall b a. b -> Either a b -> b
fromRight ([Char] -> [Job]
forall a. HasCallStack => [Char] -> a
error [Char]
"jobs error") Either Status [Job]
result)
jobs' ::
Int ->
GitLab (Either Status [Job])
jobs' :: Int -> GitLab (Either Status [Job])
jobs' Int
projectId =
Text -> GitLab (Either Status [Job])
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
"/jobs"