💎 Gitlab.cr

Tag Build Status License

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 >= v0.23.1, Docs Generated in latest commit.

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" => "[email protected]", "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"]
# => "[email protected]"

# 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)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors