Categorygithub.com/jrkt/go-gitlab
modulepackage
0.7.1
Repository: https://github.com/jrkt/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.6.0 (released on 25-08-2017) no longer supports the older V3 Gitlab API. If you need V3 support, please use the f-api-v3 branch. This release contains some backwards incompatible changes that were needed to fully support the V4 Gitlab API.

Coverage

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

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

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),
		Visibility:           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...."),
		Visibility:      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.
Visibility is a helper routine that allocates a new VisibilityValue 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.
The available todo actions.
The available todo actions.
The available todo actions.
The available todo actions.
The available todo actions.
The available todo actions.
List of valid notification levels.
The available wiki formats.
The available wiki formats.
The available wiki formats.

# 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.
AddPipelineTriggerOptions represents the available AddPipelineTrigger() 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.
BuildEvent represents a build event GitLab API docs: https://docs.gitlab.com/ce/web_hooks/web_hooks.html#build-events.
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.
CreateBuildVariableOptions are the parameters to CreateBuildVariable() Gitlab API Docs: https://docs.gitlab.com/ce/api/build_variables.html#create-variable.
CreateCommitOptions represents the available options for a new commit.
CreateEnvironmentOptions represents the available CreateEnvironment() options.
CreateFileOptions represents the available CreateFile() options.
CreateGroupOptions represents the available CreateGroup() options.
CreateImpersonationTokenOptions represents the available CreateImpersonationToken() 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.
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.
CreateWikiPageOptions represents options to CreateWikiPage.
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.
EditEnvironmentOptions represents the available EditEnvironment() options.
EditGroupMemberOptions represents the available EditGroupMember() options.
EditPipelineTriggerOptions represents the available EditPipelineTrigger() options.
EditProjectHookOptions represents the available EditProjectHook() options.
EditProjectMemberOptions represents the available EditProjectMember() options.
EditWikiPageOptions represents options to EditWikiPage.
Email represents an Email.
Environment represents a GitLab environment.
EnvironmentsService handles communication with the environment related methods of the GitLab API.
An ErrorResponse reports one or more errors caused by an API request.
Feature represents a GitLab feature flag.
FeaturesService handles the communication with the application FeaturesService related methods of the GitLab API.
File represents a GitLab repository file.
FileInfo represents file details of a GitLab repository file.
ForkParent represents the parent project when this is a fork.
Gate represents a gate of a GitLab feature flag.
GetAllImpersonationTokensOptions represents the available GetAllImpersonationTokens() options.
GetCommitStatusesOptions represents the available GetCommitStatuses() options.
GetFileOptions represents the available GetFile() options.
GetMilestoneIssuesOptions represents the available GetMilestoneIssues() options.
GetProjectEventsOptions represents the available GetProjectEvents() options.
GetRawFileOptions represents the available GetRawFile() options.
GetSessionOptions represents the available Session() options.
Group represents a GitLab group.
GroupAccess represents group access.
GroupMember represents a GitLab group member.
GroupMembersService handles communication with the group members related methods of the GitLab API.
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.
ImpersonationToken represents an impersonation token.
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.
JiraService represents Jira service settings.
JiraServiceProperties represents Jira specific properties.
Job represents a ci build.
JobsService handles communication with the ci builds related methods of the GitLab API.
Label represents a GitLab label.
LabelsService handles communication with the label related methods of the GitLab API.
ListBranchesOptions represents the available ListBranches() options.
ListBuildVariablesOptions are the parameters to ListBuildVariables() Gitlab API Docs: https://docs.gitlab.com/ce/api/build_variables.html#list-project-variables.
ListCommitsOptions represents the available ListCommits() options.
ListEnvironmentsOptions represents the available ListEnvironments() options.
ListGroupIssuesOptions represents the available ListGroupIssues() 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.
ListJobsOptions are options for two list apis.
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.
ListPipelineTriggersOptions represents the available ListPipelineTriggers() options.
ListProjectHooksOptions represents the available ListProjectHooks() options.
ListProjectIssuesOptions represents the available ListProjectIssues() options.
ListProjectMembersOptions represents the available ListProjectMembers() options.
ListProjectMergeRequestsOptions represents the available ListMergeRequests() options.
ListProjectsOptions represents the available ListProjects() options.
ListSnippetsOptions represents the available ListSnippets() options.
ListTodosOptions represents the available ListTodos() options.
ListTreeOptions represents the available ListTree() options.
ListUsersOptions represents the available ListUsers() options.
ListWikisOptions represents the available ListWikis options.
MergeCommentEvent represents a comment on a merge event.
MergeEvent represents a merge event.
MergeRequest represents a GitLab merge request.
MergeRequestApprovals represents GitLab merge request approvals.
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 available 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 permissions.
Pipeline represents a GitLab pipeline.
PipelineEvent represents a pipeline event.
PipelinesService handles communication with the repositories related methods of the GitLab API.
PipelineTrigger represents a project pipeline trigger.
PipelineTriggersService handles Project pipeline triggers.
PostCommitCommentOptions represents the available PostCommitComment() options.
Project represents a GitLab project.
ProjectAccess represents project access.
ProjectEvent represents a GitLab project event.
ProjectFile represents an uploaded project file GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#upload-a-file.
ProjectForkRelation represents a project fork relationship.
ProjectHook represents a project hook.
ProjectMember represents a project member.
ProjectMembersService handles communication with the project members related methods of the GitLab API.
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.
ProtectBranchOptions represents the available ProtectBranch() options.
PushEvent represents a push event.
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.
RunPipelineTriggerOptions represents the available RunPipelineTrigger() 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.
ShareWithGroupOptions represents options to share project with groups GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#share-project-with-group.
SlackService represents Slack service settings.
SlackServiceProperties represents Slack specific properties.
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.
Todo represents a GitLab todo.
TodosService handles communication with the todos related methods of the Gitlab API.
TodoTarget represents a todo target of type Issue or MergeRequest.
TreeNode represents a GitLab repository file or directory.
UpdateBuildVariableOptions are the parameters to UpdateBuildVariable() Gitlab API Docs: https://docs.gitlab.com/ce/api/build_variables.html#update-variable.
UpdateFileOptions represents the available UpdateFile() 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.
Version represents a GitLab instance version.
VersionService handles communication with the GitLab server instance to retrieve its version information via the GitLab API.
Wiki represents a GitLab wiki.
WikiPageEvent represents a wiki page event.
WikisService handles communication with the wikis related methods of the Gitlab API.

# Type aliases

AccessLevelValue represents a permission level within GitLab.
BuildState represents a GitLab build state.
CreateProjectForUserOptions represents the available CreateProjectForUser() options.
EditProjectOptions represents the available EditProject() options.
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.
PipelineList represents a GitLab list project pipelines GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines.
SetJiraServiceOptions represents the available SetJiraService() options.
TodoAction represents the available actions that can be performed on a todo.
UpdateGroupOptions represents the set of available options to update a Group; as of today these are exactly the same available when creating a new Group.
VisibilityValue represents a visibility level within GitLab.
WikiFormat represents the available wiki formats.