πŸ’Ž Gitlab.cr

License Version Dependency Status devDependency Status Build Status

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

Build in crystal version >= v0.20.0, Docs Generated in 9947476 (2016-12-05 17:37:25 +0800).

Installation

Stable version

Add this to your application's shard.yml:

dependencies:
  gitlab:
    github: icyleaf/gitlab.cr
    branch: master

master branch is always the latest stable release version.

Develop(Unstable) version

Add this to your application's shard.yml:

dependencies:
  gitlab:
    github: icyleaf/gitlab.cr
    branch: develop

Explicit version

Add this to your application's shard.yml, and change the version(release) what you want:

dependencies:
  gitlab:
    github: icyleaf/gitlab.cr
    version: 0.2.3

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.parse_json
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

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