class GitLab

Overview

A GitLab API client with some bells and whistles. It detects whether it's running in CI using the CI environment variable, and honours configuration from the lab.* git config sections.

Direct Known Subclasses

Defined in:

gitlab.cr
gitlab/cli.cr
gitlab/collection.cr
gitlab/context.cr
gitlab/lint.cr
gitlab/markdown.cr
gitlab/namespace.cr
gitlab/project.cr
gitlab/projects.cr
gitlab/resource.cr
gitlab/user.cr
gitlab/users.cr
gitlab/version.cr

Constant Summary

NoToken = Error.new("no GITLAB_TOKEN, set one with `git config lab.token`")

The error raised if the token is unset and cannot be determined.

VERSION = "0.0.1"

Class Method Summary

Instance Method Summary

Class Method Detail

def self.cli(op : OptionParser) #

[View source]

Instance Method Detail

def api : URI #

The REST API (v4) endpoint URI. Defaults to checking the lab.api git config value, or falls back to https://gitlab.com/api/v4. In CI, it will try the CI_API_V4_URL


[View source]
def api=(api : URI) #

The REST API (v4) endpoint URI. Defaults to checking the lab.api git config value, or falls back to https://gitlab.com/api/v4. In CI, it will try the CI_API_V4_URL


[View source]
def get(path : String, & : HTTP::Client::Response -> ) #

Gets the given resource (prepending the API path if needed) and yields the response to the block if it was successful. Non successful responses are ignored.


[View source]
def get(path : String) #

Gets the given resource. Prepends the API path if needed.


[View source]
def get(uri : URI) #

Returns the response to a GET request to the given URI.


[View source]
def home : Path #

The local directory under which to store working directories, in a hierarchy which mirrors groups, subgroups and projects. Defaults to


[View source]
def home=(home : Path) #

The local directory under which to store working directories, in a hierarchy which mirrors groups, subgroups and projects. Defaults to


[View source]
def markdown(text : String, gfm : Bool = true, project : UInt128 | String | Nil = nil) #

[View source]
def namespace #

[View source]
def post(path : String, data : NamedTuple) #

[View source]
def project #

[View source]
def project? #

[View source]
def token : String #

The bearer token used to authorize API calls. It defaults to the first value found in

    1. $GITLAB_TOKEN
    1. (only if $CI is truthy) $CI_DEPLOY_TOKEN or $CI_JOB_TOKEN
    1. the value of git-config(1) lab.token
    1. the output of executing the value of git-config(1) lab.tokenCommand

[View source]
def token=(token : String) #

The bearer token used to authorize API calls. It defaults to the first value found in

    1. $GITLAB_TOKEN
    1. (only if $CI is truthy) $CI_DEPLOY_TOKEN or $CI_JOB_TOKEN
    1. the value of git-config(1) lab.token
    1. the output of executing the value of git-config(1) lab.tokenCommand

[View source]
def user(id) : User #

[View source]
def user : Me #

[View source]
def users #

[View source]
def version #

[View source]