{-# LANGUAGE OverloadedStrings #-}
module GitLab
( runGitLab,
runGitLabDbg,
runGitLabWithManager,
module GitLab.Types,
module GitLab.API.Pipelines,
module GitLab.API.Groups,
module GitLab.API.Members,
module GitLab.API.Commits,
module GitLab.API.Projects,
module GitLab.API.Users,
module GitLab.API.Issues,
module GitLab.API.Branches,
module GitLab.API.Jobs,
module GitLab.API.MergeRequests,
module GitLab.API.Repositories,
module GitLab.API.RepositoryFiles,
module GitLab.API.Todos,
module GitLab.API.Version,
module GitLab.SystemHooks.GitLabSystemHooks,
module GitLab.SystemHooks.Types,
)
where
import Control.Monad.IO.Class
import Control.Monad.Trans.Reader
import GitLab.API.Branches
import GitLab.API.Commits
import GitLab.API.Groups
import GitLab.API.Issues
import GitLab.API.Jobs
import GitLab.API.Members
import GitLab.API.MergeRequests
import GitLab.API.Pipelines
import GitLab.API.Projects
import GitLab.API.Repositories
import GitLab.API.RepositoryFiles
import GitLab.API.Todos
import GitLab.API.Users
import GitLab.API.Version
import GitLab.SystemHooks.GitLabSystemHooks
import GitLab.SystemHooks.Types
import GitLab.Types
import Network.Connection (TLSSettings (..))
import Network.HTTP.Conduit
import Network.HTTP.Types.Status
import System.IO
runGitLab :: GitLabServerConfig -> GitLab a -> IO a
runGitLab cfg action = do
liftIO $ hSetBuffering stdout LineBuffering
let settings = mkManagerSettings (TLSSettingsSimple True False False) Nothing
manager <- liftIO $ newManager settings
runGitLabWithManager manager cfg action
runGitLabWithManager :: Manager -> GitLabServerConfig -> GitLab a -> IO a
runGitLabWithManager manager cfg action = do
tokenTest <- runReaderT gitlabVersion (GitLabState cfg manager)
case tokenTest of
Left (Status 401 "Unauthorized") -> error "access token not accepted."
Left st -> error ("unexpected HTTP status: " <> show st)
Right _versionInfo ->
runReaderT action (GitLabState cfg manager)
runGitLabDbg :: GitLab a -> IO a
runGitLabDbg action = do
liftIO $ hSetBuffering stdout LineBuffering
runReaderT action undefined