Categorygithub.com/mustafayildirim/go-gitlab
modulepackage
0.3.2
Repository: https://github.com/mustafayildirim/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.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 :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.
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.

# Constants

No description provided by the author
List of available access levels GitLab API docs: http://doc.gitlab.com/ce/permissions/permissions.html.
List of available notification levels GitLab API docs: http://doc.gitlab.com/ce/api/.
No description provided by the author
List of available notification levels GitLab API docs: http://doc.gitlab.com/ce/api/.
List of available access levels GitLab API docs: http://doc.gitlab.com/ce/permissions/permissions.html.
List of available visibility levels GitLab API docs: http://doc.gitlab.com/ce/api/.
List of available access levels GitLab API docs: http://doc.gitlab.com/ce/permissions/permissions.html.
List of available notification levels GitLab API docs: http://doc.gitlab.com/ce/api/.
List of available access levels GitLab API docs: http://doc.gitlab.com/ce/permissions/permissions.html.
List of available notification levels GitLab API docs: http://doc.gitlab.com/ce/api/.
No description provided by the author
List of available visibility levels GitLab API docs: http://doc.gitlab.com/ce/api/.
List of available visibility levels GitLab API docs: http://doc.gitlab.com/ce/api/.
List of available access levels GitLab API docs: http://doc.gitlab.com/ce/permissions/permissions.html.
No description provided by the author
No description provided by the author
List of available notification levels GitLab API docs: http://doc.gitlab.com/ce/api/.

# Structs

AddDeployKeyOptions represents the available ADDDeployKey() 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.
AddSSHKeyOptions represents the available AddSSHKey() options.
ArchiveOptions represents the available Archive() options.
No description provided by the author
Branch represents a GitLab branch.
BranchesService handles communication with the branch related methods of the GitLab API.
Build represents a ci build.
BuildsService handles communication with the ci builds related methods of the GitLab API.
A Client manages communication with the GitLab API.
Commit represents a GitLab 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.
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.
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.
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.
An Error reports more details on an individual error in an ErrorResponse.
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.
GetMergeRequestCommentsOptions represents the available GetMergeRequestComments() 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.
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.
MergeRequestComment represents a GitLab merge request comment.
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.
Permissions represents premissions.
PipelineEvent represents a pipline event.
PostCommitCommentOptions represents the available PostCommitComment() options.
PostMergeRequestCommentOptions represents the available PostMergeRequestComment() 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.
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.
No description provided by the author
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.
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.
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.
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.
No description provided by the author
Labels is a custom type with specific marshaling characteristics.
NotificationLevelValue represents a notification level within Gitlab.
VisibilityLevelValue represents a visibility level within GitLab.