Categorygithub.com/ardaxi/go-gitlab
modulepackage
0.5.1
Repository: https://github.com/ardaxi/go-gitlab.git
Documentation: pkg.go.dev

# README

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.5.0 (released on 22-03-2017) no longer supports Go versions older then 1.7.x If you want (or need) to use an older Go version please use v0.4.1

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
  • Pipelines

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 :disappointed:

Issues

Author

Sander van Harmelen ([email protected])

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

# Packages

No description provided by the author

# Functions

AccessLevel is a helper routine that allocates a new AccessLevelValue to store v and returns a pointer to it.
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
CheckResponse checks the API response for errors, and returns them if present.
Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.
NewClient returns a new GitLab API client.
NewOAuthClient returns a new GitLab API client.
NotificationLevel is a helper routine that allocates a new NotificationLevelValue to store v and returns a pointer to it.
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
Stringify attempts to create a reasonable string representation of types in the GitHub library.
VisibilityLevel is a helper routine that allocates a new VisibilityLevelValue to store v and returns a pointer to it.
WithContext runs the request with the provided context.
WithSudo takes either a username or user ID and sets the SUDO request header.

# Constants

These constants represent all valid build states.
List of valid notification levels.
List of available access levels GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html.
List of valid notification levels.
These constants represent all valid build states.
The available file actions.
The available file actions.
The available file actions.
The available file actions.
List of valid notification levels.
List of available access levels GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html.
List of available visibility levels GitLab API docs: https://docs.gitlab.com/ce/api/.
List of available access levels GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html.
List of valid notification levels.
List of available access levels GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html.
List of valid notification levels.
These constants represent all valid build states.
List of available visibility levels GitLab API docs: https://docs.gitlab.com/ce/api/.
List of available visibility levels GitLab API docs: https://docs.gitlab.com/ce/api/.
List of available access levels GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html.
These constants represent all valid build states.
These constants represent all valid build states.
List of valid notification levels.

# Structs

AcceptMergeRequestOptions represents the available AcceptMergeRequest() options.
AddDeployKeyOptions represents the available ADDDeployKey() options.
AddEmailOptions represents the available AddEmail() options.
AddGroupMemberOptions represents the available AddGroupMember() options.
AddHookOptions represents the available AddHook() options.
AddProjectHookOptions represents the available AddProjectHook() options.
AddProjectMemberOptions represents the available AddProjectMember() options.
AddSpentTimeOptions represents the available AddSpentTime() options.
AddSSHKeyOptions represents the available AddSSHKey() options.
ArchiveOptions represents the available Archive() options.
Author represents a GitLab commit author.
Branch represents a GitLab branch.
BranchesService handles communication with the branch related methods of the GitLab API.
Build represents a ci build.
BuildEvent represents a build event GitLab API docs: https://docs.gitlab.com/ce/web_hooks/web_hooks.html#build-events.
BuildsService handles communication with the ci builds related methods of the GitLab API.
BuildVariable represents a variable available for each build of the given project Gitlab API Docs : https://docs.gitlab.com/ce/api/build_variables.html.
BuildVariablesService handles communication with the project variables related methods of the Gitlab API Gitlab API Docs : https://docs.gitlab.com/ce/api/build_variables.html.
CherryPickCommitOptions represents the available options for cherry-picking a commit.
A Client manages communication with the GitLab API.
Commit represents a GitLab commit.
CommitAction represents a single file action within a commit.
CommitComment represents a GitLab commit comment.
CommitCommentEvent represents a comment on a commit event.
CommitsService handles communication with the commit related methods of the GitLab API.
CommitStats represents the number of added and deleted files in a commit.
CommitStatus represents a GitLab commit status.
Compare represents the result of a comparison of branches, tags or commits.
CompareOptions represents the available Compare() options.
Contributor represents a GitLap contributor.
CreateBranchOptions represents the available CreateBranch() options.
CreateCommitOptions represents the available options for a new commit.
CreateFileOptions represents the available CreateFile() options.
CreateGroupOptions represents the available CreateGroup() options.
CreateIssueNoteOptions represents the available CreateIssueNote() options.
CreateIssueOptions represents the available CreateIssue() options.
CreateLabelOptions represents the available CreateLabel() options.
CreateMergeRequestNoteOptions represents the available CreateMergeRequestNote() options.
CreateMergeRequestOptions represents the available CreateMergeRequest() options.
CreateMilestoneOptions represents the available CreateMilestone() options.
CreatePipelineOptions represents the available CreatePipeline() options.
CreateProjectForUserOptions represents the available CreateProjectForUser() options.
CreateProjectOptions represents the available CreateProjects() options.
CreateSnippetNoteOptions represents the available CreateSnippetNote() options.
CreateSnippetOptions represents the available CreateSnippet() options.
CreateTagOptions represents the available CreateTag() options.
CreateUserOptions represents the available CreateUser() options.
DeleteFileOptions represents the available DeleteFile() options.
DeleteLabelOptions represents the available DeleteLabel() options.
DeployKey represents a GitLab deploy key.
DeployKeysService handles communication with the keys related methods of the GitLab API.
Diff represents a GitLab diff.
DroneCIService represents Drone CI service settings.
DroneCIServiceProperties represents Drone CI specific properties.
EditProjectHookOptions represents the available EditProjectHook() options.
EditProjectMemberOptions represents the available EditProjectMember() options.
EditProjectOptions represents the available EditProject() options.
Email represents an Email.
An ErrorResponse reports one or more errors caused by an API request.
File represents a GitLab repository file.
FileInfo represents file details of a GitLab repository file.
GetCommitStatusesOptions represents the available GetCommitStatuses() options.
GetFileOptions represents the available GetFile() options.
GetMilestoneIssuesOptions represents the available GetMilestoneIssues() options.
GetProjectEventsOptions represents the available GetProjectEvents() options.
GetSessionOptions represents the available Session() options.
Group represents a GitLab group.
GroupAccess represents group access.
GroupMember represents a GitLab group member.
GroupsService handles communication with the group related methods of the GitLab API.
Hook represents a GitLap system hook.
HookEvent represents an event triggert by a GitLab system hook.
Issue represents a GitLab issue.
IssueCommentEvent represents a comment on an issue event.
IssueEvent represents a issue event.
IssuesService handles communication with the issue related methods of the GitLab API.
Label represents a GitLab label.
LabelsService handles communication with the label related methods of the GitLab API.
ListBuildsOptions are options for two list apis.
ListCommitsOptions represents the available ListCommits() options.
ListGroupMembersOptions represents the available ListGroupMembers() options.
ListGroupProjectsOptions represents the available ListGroupProjects() options.
ListGroupsOptions represents the available ListGroups() options.
ListIssueNotesOptions represents the available ListIssueNotes() options.
ListIssuesOptions represents the available ListIssues() options.
ListMergeRequestsOptions represents the available ListMergeRequests() options.
ListMilestonesOptions represents the available ListMilestones() options.
ListNamespacesOptions represents the available ListNamespaces() options.
ListOptions specifies the optional parameters to various List methods that support pagination.
ListProjectHooksOptions represents the available ListProjectHooks() options.
ListProjectIssuesOptions represents the available ListProjectIssues() options.
ListProjectMembersOptions represents the available ListProjectMembers() options.
ListProjectsOptions represents the available ListProjects() options.
ListSnippetsOptions represents the available ListSnippets() options.
ListTreeOptions represents the available ListTree() options.
ListUsersOptions represents the available ListUsers() options.
MergeCommentEvent represents a comment on a merge event.
MergeEvent represents a merge event.
MergeRequest represents a GitLab merge request.
MergeRequestsService handles communication with the merge requests related methods of the GitLab API.
Milestone represents a GitLab milestone.
MilestonesService handles communication with the milestone related methods of the GitLab API.
ModifyUserOptions represents the available ModifyUser() options.
Namespace represents a GitLab namespace.
NamespacesService handles communication with the namespace related methods of the GitLab API.
Note represents a GitLab note.
NotesService handles communication with the notes related methods of the GitLab API.
NotificationEvents represents the avialable notification setting events.
NotificationSettings represents the Gitlab notification setting.
NotificationSettingsOptions represents the available options that can be passed to the API when updating the notification settings.
NotificationSettingsService handles communication with the notification settings related methods of the GitLab API.
Permissions represents premissions.
Pipeline represents a GitLab pipeline.
PipelineEvent represents a pipeline event.
PipelinesService handles communication with the repositories related methods of the GitLab API.
PostCommitCommentOptions represents the available PostCommitComment() options.
Project represents a GitLab project.
ProjectAccess represents project access.
ProjectEvent represents a GitLab project event.
ProjectForkRelation represents a project fork relationship.
ProjectHook represents a project hook.
ProjectMember represents a project member.
ProjectNamespace represents a project namespace.
ProjectSnippetsService handles communication with the project snippets related methods of the GitLab API.
ProjectsService handles communication with the repositories related methods of the GitLab API.
ProjectStatistics represents a statistics record for a project.
PushEvent represents a push event.
RawFileContentOptions represents the available RawFileContent() options.
RepositoriesService handles communication with the repositories related methods of the GitLab API.
Repository represents a repository.
RepositoryFilesService handles communication with the repository files related methods of the GitLab API.
Response is a GitLab API response.
SearchProjectsOptions represents the available SearchProjects() options.
Service represents a GitLab service.
ServicesService handles communication with the services related methods of the GitLab API.
Session represents a GitLab session.
SessionService handles communication with the session related methods of the GitLab API.
SetCommitStatusOptions represents the available SetCommitStatus() options.
SetDroneCIServiceOptions represents the available SetDroneCIService() options.
SetGitLabCIServiceOptions represents the available SetGitLabCIService() options.
SetHipChatServiceOptions represents the available SetHipChatService() options.
SetSlackServiceOptions represents the available SetSlackService() options.
SetTimeEstimateOptions represents the available SetTimeEstimate() options.
Settings represents the GitLab application settings.
SettingsService handles communication with the application SettingsService related methods of the GitLab API.
Snippet represents a GitLab project snippet.
SnippetCommentEvent represents a comment on a snippet event.
SSHKey represents a SSH key.
StorageStatistics represents a statistics record for a group or project.
SystemHooksService handles communication with the system hooks related methods of the GitLab API.
Tag represents a GitLab tag.
TagEvent represents a tag event.
TagsService handles communication with the tags related methods of the GitLab API.
TimeStats represents the time estimates and time spent for an issue.
TimeStatsService handles communication with the time tracking related methods of the GitLab API.
TreeNode represents a GitLab repository file or directory.
UpdateFileOptions represents the available UpdateFile() options.
UpdateGroupMemberOptions represents the available UpdateGroupMember() options.
UpdateIssueNoteOptions represents the available UpdateIssueNote() options.
UpdateIssueOptions represents the available UpdateIssue() options.
UpdateLabelOptions represents the available UpdateLabel() options.
UpdateMergeRequestNoteOptions represents the available UpdateMergeRequestNote() options.
UpdateMergeRequestOptions represents the available UpdateMergeRequest() options.
UpdateMilestoneOptions represents the available UpdateMilestone() options.
UpdateSettingsOptions represents the available UpdateSettings() options.
UpdateSnippetNoteOptions represents the available UpdateSnippetNote() options.
UpdateSnippetOptions represents the available UpdateSnippet() options.
User represents a GitLab user.
UserIdentity represents a user identity.
UsersService handles communication with the user related methods of the GitLab API.
WikiPageEvent represents a wiki page event.

# Type aliases

AccessLevelValue represents a permission level within GitLab.
BuildState represents a GitLab build state.
FileAction represents the available actions that can be performed on a file.
Labels is a custom type with specific marshaling characteristics.
NotificationLevelValue represents a notification level.
OptionFunc can be passed to all API requests to make the API call as if you were another user, provided your private token is from an administrator account.
VisibilityLevelValue represents a visibility level within GitLab.