{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GitLab.API.Discussions
(
projectIssueDiscussions,
issueDiscussion,
createIssueThread,
addNoteToIssueThread,
modifyThreadNoteIssue,
deleteIssueThreadNote,
snippetDiscussionItems,
snippetDiscussionItem,
createSnippetThread,
addNoteToSnippetThread,
modifySnippetThreadNote,
deleteSnippetThreadNote,
projectMergeRequestDiscussionItems,
mergeRequestDiscussionItems,
createMergeRequestThread,
resolveMergeRequestThread,
addNoteToMergeRequestThread,
modifyMergeRequestThreadNote,
deleteMergeRequestThreadNote,
projectCommitDiscussionItems,
projectCommitDiscussionItem,
createCommitThread,
addNoteToCommitThread,
modifyCommityThreadNote,
deleteCommitThreadNote,
PositionReference (..),
)
where
import qualified Data.ByteString.Lazy as BSL
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Client
projectIssueDiscussions ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Discussion])
projectIssueDiscussions :: Project
-> Int -> GitLab (Either (Response ByteString) [Discussion])
projectIssueDiscussions Project
prj Int
issueIid = do
let urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/issues/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
issueIid
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions"
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) [Discussion])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany Text
urlPath []
issueDiscussion ::
Project ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
issueDiscussion :: Project
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe Discussion))
issueDiscussion Project
prj Int
issueIid Int
discussionId = do
let urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/issues/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
issueIid
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
discussionId
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabGetOne Text
urlPath []
createIssueThread ::
Project ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
createIssueThread :: Project
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
createIssueThread Project
prj Int
issueIid Text
threadContent = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost Text
discussionAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
threadContent))]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/issues/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
issueIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions"
addNoteToIssueThread ::
Project ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
addNoteToIssueThread :: Project
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
addNoteToIssueThread Project
prj Int
issueIid Int
discussionId Text
content = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost Text
discussionAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/issues/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
issueIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes"
modifyThreadNoteIssue ::
Project ->
Int ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
modifyThreadNoteIssue :: Project
-> Int
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
modifyThreadNoteIssue Project
prj Int
issueIid Int
discussionId Int
noteId Text
content = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPut Text
noteAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))]
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/issues/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
issueIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
deleteIssueThreadNote ::
Project ->
Int ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
deleteIssueThreadNote :: Project
-> Int
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe ()))
deleteIssueThreadNote Project
prj Int
issueIid Int
discussionId Int
noteId = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe ()))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabDelete Text
noteAddr []
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/issues/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
issueIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
snippetDiscussionItems ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Discussion])
snippetDiscussionItems :: Project
-> Int -> GitLab (Either (Response ByteString) [Discussion])
snippetDiscussionItems Project
prj Int
snippetId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) [Discussion])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/snippets/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
snippetId
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions"
snippetDiscussionItem ::
Project ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
snippetDiscussionItem :: Project
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe Discussion))
snippetDiscussionItem Project
prj Int
snippetId Int
discussionId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabGetOne Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/snippets/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
snippetId
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
discussionId
createSnippetThread ::
Project ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
createSnippetThread :: Project
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
createSnippetThread Project
prj Int
snippetId Text
content = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost Text
discussionAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/snippets/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
snippetId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions"
addNoteToSnippetThread ::
Project ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
addNoteToSnippetThread :: Project
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
addNoteToSnippetThread Project
prj Int
snippetId Int
discussionId Text
content =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost Text
discussionAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/snippets/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
snippetId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes"
modifySnippetThreadNote ::
Project ->
Int ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
modifySnippetThreadNote :: Project
-> Int
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
modifySnippetThreadNote Project
prj Int
snippetId Int
discussionId Int
noteId Text
content =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPut Text
noteAddr [(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))]
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/snippets/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
snippetId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
deleteSnippetThreadNote ::
Project ->
Int ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
deleteSnippetThreadNote :: Project
-> Int
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe ()))
deleteSnippetThreadNote Project
prj Int
snippetId Int
discussionId Int
noteId = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe ()))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabDelete Text
noteAddr []
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/snippets/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
snippetId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
projectMergeRequestDiscussionItems ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Discussion])
projectMergeRequestDiscussionItems :: Project
-> Int -> GitLab (Either (Response ByteString) [Discussion])
projectMergeRequestDiscussionItems Project
prj Int
mergeRequestIid = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) [Discussion])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/merge_requests/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions"
mergeRequestDiscussionItems ::
Project ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
mergeRequestDiscussionItems :: Project
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe Discussion))
mergeRequestDiscussionItems Project
prj Int
mergeRequestIid Int
discussionId = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabGetOne Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/merge_requests/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
discussionId
data PositionReference = TextPos | ImagePos
instance Show PositionReference where
show :: PositionReference -> String
show PositionReference
TextPos = String
"text"
show PositionReference
ImagePos = String
"image"
createMergeRequestThread ::
Project ->
Int ->
Text ->
Text ->
Text ->
Text ->
PositionReference ->
Text ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
createMergeRequestThread :: Project
-> Int
-> Text
-> Text
-> Text
-> Text
-> PositionReference
-> Text
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
createMergeRequestThread Project
prj Int
mergeRequestIid Text
content Text
baseCommitShaSource Text
shaCommitTarget Text
shaHeadMR PositionReference
typePosRef Text
filePathAfter Text
filePathBefore =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost
Text
discussionAddr
[ (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content)),
(ByteString
"position[base_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
baseCommitShaSource)),
(ByteString
"position[start_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
shaCommitTarget)),
(ByteString
"position[head_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
shaHeadMR)),
(ByteString
"position[position_type]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 (String -> Text
T.pack (PositionReference -> String
forall a. Show a => a -> String
show PositionReference
typePosRef)))),
(ByteString
"position[new_path]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
filePathAfter)),
(ByteString
"position[old_path]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
filePathBefore))
]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/merge_requests/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions"
resolveMergeRequestThread ::
Project ->
Int ->
Int ->
Bool ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
resolveMergeRequestThread :: Project
-> Int
-> Int
-> Bool
-> GitLab (Either (Response ByteString) (Maybe Discussion))
resolveMergeRequestThread Project
prj Int
mergeRequestIid Int
discussionId Bool
resolved =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPut Text
noteAddr [(ByteString
"resolved", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 (Bool -> Text
forall {a}. IsString a => Bool -> a
resolvedStr Bool
resolved)))]
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/merge_requests/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
resolvedStr :: Bool -> a
resolvedStr Bool
True = a
"true"
resolvedStr Bool
False = a
"false"
addNoteToMergeRequestThread ::
Project ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
addNoteToMergeRequestThread :: Project
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
addNoteToMergeRequestThread Project
prj Int
mergeRequestIid Int
discussionId Text
content =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost
Text
discussionAddr
[ (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))
]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/merge_requests/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes"
modifyMergeRequestThreadNote ::
Project ->
Int ->
Int ->
Int ->
Maybe Text ->
Maybe Bool ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
modifyMergeRequestThreadNote :: Project
-> Int
-> Int
-> Int
-> Maybe Text
-> Maybe Bool
-> GitLab (Either (Response ByteString) (Maybe Discussion))
modifyMergeRequestThreadNote Project
prj Int
mergeRequestIid Int
discussionId Int
noteId Maybe Text
content Maybe Bool
resolved =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPut
Text
noteAddr
([Maybe GitLabParam] -> [GitLabParam]
forall a. [Maybe a] -> [a]
catMaybes [Maybe GitLabParam
contentAttr, Maybe GitLabParam
resolveAttr])
where
contentAttr :: Maybe GitLabParam
contentAttr =
case Maybe Text
content of
Maybe Text
Nothing -> Maybe GitLabParam
forall a. Maybe a
Nothing
Just Text
x -> GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
x))
resolveAttr :: Maybe GitLabParam
resolveAttr =
case Maybe Bool
resolved of
Maybe Bool
Nothing -> Maybe GitLabParam
forall a. Maybe a
Nothing
Just Bool
x ->
if Bool
x
then GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"resolved", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
"true"))
else GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"resolved", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
"false"))
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/merge_requests/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
deleteMergeRequestThreadNote ::
Project ->
Int ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
deleteMergeRequestThreadNote :: Project
-> Int
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe ()))
deleteMergeRequestThreadNote Project
prj Int
mergeRequestIid Int
discussionId Int
noteId = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe ()))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabDelete Text
noteAddr []
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/merge_requests/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIid)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
projectCommitDiscussionItems ::
Project ->
Int ->
GitLab (Either (Response BSL.ByteString) [Discussion])
projectCommitDiscussionItems :: Project
-> Int -> GitLab (Either (Response ByteString) [Discussion])
projectCommitDiscussionItems Project
prj Int
commitId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) [Discussion])
forall a.
FromJSON a =>
Text -> [GitLabParam] -> GitLab (Either (Response ByteString) [a])
gitlabGetMany Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/commits/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
commitId
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions"
projectCommitDiscussionItem ::
Project ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
projectCommitDiscussionItem :: Project
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe Discussion))
projectCommitDiscussionItem Project
prj Int
commitId Int
discussionId =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabGetOne Text
urlPath []
where
urlPath :: Text
urlPath =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Project -> Int
project_id Project
prj)
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/commits/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
commitId
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/discussions/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
discussionId
createCommitThread ::
Project ->
Int ->
Text ->
Text ->
Text ->
Text ->
PositionReference ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
createCommitThread :: Project
-> Int
-> Text
-> Text
-> Text
-> Text
-> PositionReference
-> GitLab (Either (Response ByteString) (Maybe Discussion))
createCommitThread Project
prj Int
commitId Text
content Text
shaParent Text
shaStart Text
shaThisCommit PositionReference
typePosRef =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost
Text
discussionAddr
[ (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content)),
(ByteString
"position[base_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
shaParent)),
(ByteString
"position[start_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
shaStart)),
(ByteString
"position[head_sha]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
shaThisCommit)),
(ByteString
"position[position_type]", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 (String -> Text
T.pack (PositionReference -> String
forall a. Show a => a -> String
show PositionReference
typePosRef))))
]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/commits/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
commitId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions"
addNoteToCommitThread ::
Project ->
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
addNoteToCommitThread :: Project
-> Int
-> Int
-> Text
-> GitLab (Either (Response ByteString) (Maybe Discussion))
addNoteToCommitThread Project
prj Int
commitId Int
discussionId Text
content =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost
Text
discussionAddr
[ (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
content))
]
where
discussionAddr :: Text
discussionAddr :: Text
discussionAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/commits/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
commitId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes"
modifyCommityThreadNote ::
Project ->
Int ->
Int ->
Int ->
Maybe Text ->
Maybe Bool ->
GitLab (Either (Response BSL.ByteString) (Maybe Discussion))
modifyCommityThreadNote :: Project
-> Int
-> Int
-> Int
-> Maybe Text
-> Maybe Bool
-> GitLab (Either (Response ByteString) (Maybe Discussion))
modifyCommityThreadNote Project
prj Int
commitId Int
discussionId Int
noteId Maybe Text
content Maybe Bool
resolved =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe Discussion))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPut
Text
noteAddr
([Maybe GitLabParam] -> [GitLabParam]
forall a. [Maybe a] -> [a]
catMaybes [Maybe GitLabParam
contentAttr, Maybe GitLabParam
resolveAttr])
where
contentAttr :: Maybe GitLabParam
contentAttr =
case Maybe Text
content of
Maybe Text
Nothing -> Maybe GitLabParam
forall a. Maybe a
Nothing
Just Text
x -> GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
x))
resolveAttr :: Maybe GitLabParam
resolveAttr =
case Maybe Bool
resolved of
Maybe Bool
Nothing -> Maybe GitLabParam
forall a. Maybe a
Nothing
Just Bool
x ->
if Bool
x
then GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"resolved", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
"true"))
else GitLabParam -> Maybe GitLabParam
forall a. a -> Maybe a
Just (ByteString
"resolved", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
"false"))
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/commits/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
commitId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)
deleteCommitThreadNote ::
Project ->
Int ->
Int ->
Int ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
deleteCommitThreadNote :: Project
-> Int
-> Int
-> Int
-> GitLab (Either (Response ByteString) (Maybe ()))
deleteCommitThreadNote Project
prj Int
commitId Int
discussionId Int
noteId = do
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe ()))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabDelete Text
noteAddr []
where
noteAddr :: Text
noteAddr :: Text
noteAddr =
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 (Project -> Int
project_id Project
prj))
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/commits/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
commitId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/discussions/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
discussionId)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/notes/"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
noteId)