{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Pipelines where
import qualified Data.ByteString.Lazy as BSL
import Data.Either
import qualified Data.Text as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Client
pipelines ::
Project ->
GitLab [Pipeline]
pipelines :: Project -> GitLab [Pipeline]
pipelines Project
p = do
Either (Response ByteString) [Pipeline]
result <- Int -> GitLab (Either (Response ByteString) [Pipeline])
pipelines' (Project -> Int
project_id Project
p)
[Pipeline] -> GitLab [Pipeline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pipeline] -> Either (Response ByteString) [Pipeline] -> [Pipeline]
forall b a. b -> Either a b -> b
fromRight ([Char] -> [Pipeline]
forall a. HasCallStack => [Char] -> a
error [Char]
"pipelines error") Either (Response ByteString) [Pipeline]
result)
pipelines' ::
Int ->
GitLab (Either (Response BSL.ByteString) [Pipeline])
pipelines' :: Int -> GitLab (Either (Response ByteString) [Pipeline])
pipelines' Int
projectId =
Text -> Text -> GitLab (Either (Response ByteString) [Pipeline])
forall a.
FromJSON a =>
Text -> Text -> GitLab (Either (Response ByteString) [a])
gitlabWithAttrs
Text
addr
Text
"&sort=desc"
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
"/pipelines"