A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way
Go
Permalink
Failed to load latest commit information.
examples Convert all *Options structs to use pointer for fields and fixup the … Jul 26, 2016
.gitignore Initial commit Mar 29, 2015
.travis.yml Add tag service and update repository file options (#72) Sep 26, 2016
CHANGELOG.md Update the CHANGELOG.md Sep 26, 2016
LICENSE Initial commit Mar 29, 2015
README.md Convert all *Options structs to use pointer for fields and fixup the … Jul 26, 2016
branches.go Update all documentation links (#106) Dec 11, 2016
build_variables.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
build_variables_test.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
builds.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
commits.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
commits_test.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
deploy_keys.go Update all documentation links (#106) Dec 11, 2016
events.go Fix event structs (#109) Dec 12, 2016
events_test.go PipelineEvent type changed (#99) Dec 2, 2016
gitlab.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
gitlab_test.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
groups.go ListGroupProjects implementation (#110) Dec 12, 2016
issues.go Update all documentation links (#106) Dec 11, 2016
labels.go Update all documentation links (#106) Dec 11, 2016
merge_requests.go Update all documentation links (#106) Dec 11, 2016
milestones.go Update all documentation links (#106) Dec 11, 2016
namespaces.go Update all documentation links (#106) Dec 11, 2016
notes.go Update all documentation links (#106) Dec 11, 2016
project_snippets.go Update all documentation links (#106) Dec 11, 2016
projects.go Adds only_allow_merge_if_all_discussions_are_resolved and approvals_b… Dec 28, 2016
projects_test.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
repositories.go Update all documentation links (#106) Dec 11, 2016
repository_files.go Update all documentation links (#106) Dec 11, 2016
services.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
services_test.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
session.go Update all documentation links (#106) Dec 11, 2016
settings.go Update all documentation links (#106) Dec 11, 2016
strings.go Warning fixes and other cleanups (#62) Jul 27, 2016
system_hooks.go Update all documentation links (#106) Dec 11, 2016
tags.go Fix linting errors and refactor build variables code (#113) Dec 29, 2016
users.go Update all documentation links (#106) Dec 11, 2016

README.md

go-gitlab

A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way

Documentation: GoDoc Build Status: Build Status

NOTE

Release v0.2.0 (released on 26-07-2016), is unfortunately backwards incompatible. We understand very well that this will cause some additional work in order to get your code working again, but we believe this is a necessary eval to improve functionality and fix some use cases (see GH-29 and GH-53).

Coverage

This API client package covers 100% of the existing GitLab API calls! So this includes all calls to the following services:

  • Users
  • Session
  • Projects (including setting Webhooks)
  • Project Snippets
  • Services
  • Repositories
  • Repository Files
  • Commits
  • Branches
  • Merge Requests
  • Issues
  • Labels
  • Milestones
  • Notes (comments)
  • Deploy Keys
  • System Hooks
  • Groups
  • Namespaces
  • Settings

Usage

import "github.com/xanzy/go-gitlab"

Construct a new GitLab client, then use the various services on the client to access different parts of the GitLab API. For example, to list all users:

git := gitlab.NewClient(nil, "yourtokengoeshere")
//git.SetBaseURL("https://git.mydomain.com/api/v3")
users, _, err := git.Users.ListUsers()

Some API methods have optional parameters that can be passed. For example, to list all projects for user "svanharmelen":

git := gitlab.NewClient(nil)
opt := &ListProjectsOptions{Search: gitlab.String("svanharmelen")})
projects, _, err := git.Projects.ListProjects(opt)

Examples

The examples directory contains a couple for clear examples, of which one is partially listed here as well:

package main

import (
    "log"

    "github.com/xanzy/go-gitlab"
)

func main() {
    git := gitlab.NewClient(nil, "yourtokengoeshere")

    // Create new project
    p := &gitlab.CreateProjectOptions{
        Name:                 gitlab.String("My Project"),
        Description:          gitlab.String("Just a test project to play with"),
        MergeRequestsEnabled: gitlab.Bool(true),
        SnippetsEnabled:      gitlab.Bool(true),
        VisibilityLevel:      gitlab.VisibilityLevel(gitlab.PublicVisibility),
    }
    project, _, err := git.Projects.CreateProject(p)
    if err != nil {
        log.Fatal(err)
    }

    // Add a new snippet
    s := &gitlab.CreateSnippetOptions{
        Title:           gitlab.String("Dummy Snippet"),
        FileName:        gitlab.String("snippet.go"),
        Code:            gitlab.String("package main...."),
        VisibilityLevel: gitlab.VisibilityLevel(gitlab.PublicVisibility),
    }
    _, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
    if err != nil {
        log.Fatal(err)
    }
}

For complete usage of go-gitlab, see the full package docs.

ToDo

  • The biggest thing this package still needs is tests 😞

Issues

Author

Sander van Harmelen (sander@xanzy.io)

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0