gitlab-haskell: A Haskell library for the GitLab web API

[ bsd3, git, library ] [ Propose Tags ]

This Haskell library queries and updates the database of a GitLab instance using the GitLab web API: https://docs.gitlab.com/ee/api/

It also features an API for writing Gitlab file hook applications

Run all GitLab actions with runGitLab:

runGitLab ::
 => GitLabServerConfig -- ^ the GitLab server details
 -> GitLab a           -- ^ the GitLab action
 -> IO a

For example:

myProjects <- runGitLab
     (defaultGitLabServer
         { url = "https://gitlab.example.com"
         , token="my_token"} )
     (searchUser "joe" >>= userProjects . fromJust)

Which uses the functions:

searchUser   :: Text -> GitLab (Maybe User)
userProjects :: User -> GitLab (Maybe [Project])
projectCommits :: Project -> GitLab [Commit]

This library can also be used to develop rule based GitLab file hooks that react in real time to GitLab events with:

receive :: [Rule] -> GitLab ()
class (FromJSON a) => SystemHook a where
  match   :: String -> (a -> GitLab ()) -> Rule
  matchIf :: String -> (a -> GitLab Bool) -> (a -> GitLab ()) -> Rule

For more details about the file hooks support: https://www.macs.hw.ac.uk/~rs46/posts/2020-06-06-gitlab-system-hooks.html

Unsurprisingly, this library is maintained on GitLab: https://gitlab.com/robstewart57/gitlab-haskell


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.3.0, 0.3.0.1, 0.3.0.2, 0.3.1, 0.3.1.1
Dependencies aeson (>=1.4.4.0), base (>=4.7 && <5), bytestring, connection, http-client, http-conduit, http-types, temporary, text, time (>=1.9), transformers, unix [details]
License BSD-3-Clause
Copyright 2021 Rob Stewart, Heriot-Watt University
Author Rob Stewart
Maintainer robstewart57@gmail.com
Category Git
Home page https://gitlab.com/robstewart57/gitlab-haskell
Bug tracker https://gitlab.com/robstewart57/gitlab-haskell/issues
Source repo head: git clone https://gitlab.com/robstewart57/gitlab-haskell
Uploaded by RobStewart at 2021-09-06T15:31:45Z
Distributions LTSHaskell:0.2.5, NixOS:0.2.5, Stackage:0.3.1.1
Downloads 4885 total (517 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs not available [build log]
Last success reported on 2021-09-06 [all 1 reports]

Modules

  • GitLab
    • API
      • GitLab.API.Boards
      • GitLab.API.Branches
      • GitLab.API.Commits
      • GitLab.API.Discussions
      • GitLab.API.Groups
      • GitLab.API.Issues
      • GitLab.API.Jobs
      • GitLab.API.Members
      • GitLab.API.MergeRequests
      • GitLab.API.Notes
      • GitLab.API.Pipelines
      • GitLab.API.Projects
      • GitLab.API.Repositories
      • GitLab.API.RepositoryFiles
      • GitLab.API.Tags
      • GitLab.API.Todos
      • GitLab.API.Users
      • GitLab.API.Version
    • SystemHooks
      • GitLab.SystemHooks.GitLabSystemHooks
      • GitLab.SystemHooks.Rules
      • GitLab.SystemHooks.Types
    • GitLab.Types

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for gitlab-haskell-0.3.1.1

[back to package description]

A Haskell library for the GitLab web API

This library interacts with a GitLab server's API. It supports queries about and updates to:

  • Branches
  • Commits
  • Groups
  • Issues
  • Jobs
  • Members
  • Merge requests
  • Pipelines
  • Projects
  • Repositories
  • Repository files
  • Users
  • Discussions
  • Tags
  • Todos
  • Version
  • Notes
  • Boards

The library parses JSON results into Haskell data types in the GitLab.Types module, allowing you to work with statically typed GitLab data with data types and functions that the library provides. E.g.

searchUser     :: Text -> GitLab (Maybe User)
userProjects   :: User -> GitLab (Maybe [Project])
projectCommits :: Project -> GitLab [Commit]

Example

Run all GitLab actions with runGitLab:

runGitLab ::
   => GitLabServerConfig
   -> GitLab a
   -> IO a

For example:

myProjects <-
  runGitLab
    (defaultGitLabServer
       { url = "https://gitlab.example.com"
       , token="my_token"} )
    (searchUser "joe" >>= userProjects . fromJust)

This library can also be used to implement rule based GitLab file system hooks that, when deployed a GitLab server, react in real time to GitLab events like project creation, new users, merge requests etc.

The rule based API for implementing file hooks is:

receive :: [Rule] -> GitLab ()

class (FromJSON a) => SystemHook a where
  match   :: String -> (a -> GitLab ()) -> Rule
  matchIf :: String -> (a -> GitLab Bool) -> (a -> GitLab ()) -> Rule

For more details about the file system hooks support, see post: GitLab automation with file hook rules.

For the complete gitlab-haskell API, see the hackage documentation.

The gitlab-tools command line tool for bulk GitLab transactions uses this library link.