{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Jobs
(
jobs,
pipelineJobs,
pipelineBridges,
job,
cancelJob,
retryJob,
eraseJob,
runJob,
)
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
jobs ::
Project ->
GitLab [Job]
jobs :: Project -> GitLab [Job]
jobs Project
project = do
Either (Response ByteString) [Job]
result <- Int -> GitLab (Either (Response ByteString) [Job])
jobs' (Project -> Int
project_id Project
project)
[Job] -> GitLab [Job]
forall a. a -> GitLabT IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Job] -> Either (Response ByteString) [Job] -> [Job]
forall b a. b -> Either a b -> b
fromRight ([Char] -> [Job]
forall a. HasCallStack => [Char] -> a
error [Char]
"jobs error") Either (Response ByteString) [Job]
result)
jobs' ::
Int ->
GitLab (Either (Response BSL.ByteString) [Job])
jobs' :: Int -> GitLab (Either (Response ByteString) [Job])
jobs' Int
projectId =
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) [Job])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany 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"
pipelineJobs ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Job])
pipelineJobs :: Project -> Int -> GitLab (Either (Response ByteString) [Job])
pipelineJobs Project
prj Int
pipelineId =
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) [Job])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/pipelines/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
pipelineId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs"
pipelineBridges ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Job])
pipelineBridges :: Project -> Int -> GitLab (Either (Response ByteString) [Job])
pipelineBridges Project
prj Int
pipelineId =
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) [Job])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/pipelines/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
pipelineId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/bridges"
job ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Job))
job :: Project -> Int -> GitLab (Either (Response ByteString) (Maybe Job))
job Project
prj Int
jobId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Job))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabGetOne 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
jobId)
cancelJob ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Job))
cancelJob :: Project -> Int -> GitLab (Either (Response ByteString) (Maybe Job))
cancelJob Project
prj Int
jobId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Job))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
jobId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/cancel"
retryJob ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Job))
retryJob :: Project -> Int -> GitLab (Either (Response ByteString) (Maybe Job))
retryJob Project
prj Int
jobId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Job))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
jobId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/cancel"
eraseJob ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Job))
eraseJob :: Project -> Int -> GitLab (Either (Response ByteString) (Maybe Job))
eraseJob Project
prj Int
jobId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Job))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
jobId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/erase"
runJob ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Job))
runJob :: Project -> Int -> GitLab (Either (Response ByteString) (Maybe Job))
runJob Project
prj Int
jobId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Job))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost 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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/jobs/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
jobId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/play"