{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Tags where
import Data.Either
import Data.Text (Text)
import qualified Data.Text as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Types.Status
tags ::
Project ->
GitLab [Tag]
tags :: Project -> GitLab [Tag]
tags Project
project = do
Either Status [Tag]
result <- Int -> GitLab (Either Status [Tag])
tags' (Project -> Int
project_id Project
project)
[Tag] -> GitLab [Tag]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Tag] -> Either Status [Tag] -> [Tag]
forall b a. b -> Either a b -> b
fromRight [] Either Status [Tag]
result)
tags' ::
Int ->
GitLab (Either Status [Tag])
tags' :: Int -> GitLab (Either Status [Tag])
tags' Int
projectId = do
Text -> Text -> GitLab (Either Status [Tag])
forall a. FromJSON a => Text -> Text -> GitLab (Either Status [a])
gitlabWithAttrs (Int -> Text
commitsAddr Int
projectId) Text
""
where
commitsAddr :: Int -> Text
commitsAddr :: Int -> Text
commitsAddr Int
projId =
Text
"/projects/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
projId) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/repository" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/tags"