💎 Gitlab.cr

Language Tag Build Status

Gitlab.cr is a GitLab API wrapper writes with Crystal Language. Inspired from gitlab gem for ruby version. No support GraphQL API

Build in crystal version >= v1.0.0, Docs Generated in 00e176b (2021-03-24 11:48:16 +0800).

Installation

dependencies:
  gitlab:
    github: icyleaf/gitlab.cr

Usage

require "gitlab"

# configuration
endpoint = "http://domain.com/api/v3"
token = "<token>"

# initialize a new client
g = Gitlab.client(endpoint, token)
# => #<Gitlab::Client:0x101653f20 @endpoint="http://localhost:10080/api/v3", @token="xxx">

# get the authenticated user
user = g.user
# => {"name" => "icyleaf", "username" => "icyleaf", "id" => 34, "state" => "active", "avatar_url" => "http://www.gravatar.com/avatar/38e1b2eb5d0a3fff4fb0ab8363c8f874?s=80&d=identicon", "web_url" => "http://gitlab.docker:10080/u/icyleaf", "created_at" => "2016-05-14T09:23:42.594+05:30", "is_admin" => true, "bio" => nil, "location" => nil, "skype" => "", "linkedin" => "", "twitter" => "", "website_url" => "", "last_sign_in_at" => "2016-05-14T09:24:00.575+05:30", "confirmed_at" => "2016-05-14T09:23:42.457+05:30", "email" => "icyleaf.cn@gmail.com", "theme_id" => 2, "color_scheme_id" => 1, "projects_limit" => 8, "current_sign_in_at" => "2016-06-18T20:11:15.609+05:30", "identities" => [], "can_create_group" => true, "can_create_project" => true, "two_factor_enabled" => false, "external" => false, "private_token" => "xxx"}

# get the user's email
email = user["email"]
# => "icyleaf.cn@gmail.com"

# get list of projects
projects = g.projects({ "per_page" => 5 })

# handle the exception
begin
  pp g.delete_group(999)
rescue ex
  pp ex.message
  # Here has one variable "response" instance of Gitlab::HTTP::Response
  # Friendly for developer to debug and control expressions.
  pp ex.response.code
  pp ex.response.body
end

# request not handled APIs
# example: request a GET method to call "/application/settings"

# get gitlab settings
g.get("/application/settings")

# update gitlab settings
g.put("/application/settings", { "signup_enabled" => "false" })

For more information, refer to API Documentation.

Progress

Built-in

Gitlab

Completed

Todo (optional)

Help and Discussion

You can browse the API documents:

http://icyleaf.github.io/gitlab.cr/

You can browse the Changelog:

https://github.com/icyleaf/gitlab.cr/blob/master/CHANGELOG.md

If you have found a bug, please create a issue here:

https://github.com/icyleaf/gitlab.cr/issues/new

How to Contribute

Your contributions are always welcome! Please submit a pull request or create an issue to add a new question, bug or feature to the list.

All Contributors are on the wall.

You may also like

License

MIT License © icyleaf