• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/workflows/H11-Aug-2021-

examples/H11-Aug-2021-

testdata/H11-Aug-2021-

.gitignoreH A D11-Aug-2021312

.golangci.ymlH A D11-Aug-20211.1 KiB

LICENSEH A D11-Aug-202111.1 KiB

README.mdH A D11-Aug-20215.3 KiB

access_requests.goH A D11-Aug-20217.6 KiB

access_requests_test.goH A D11-Aug-202112.4 KiB

applications.goH A D11-Aug-20213.4 KiB

applications_test.goH A D11-Aug-20212.6 KiB

audit_events.goH A D11-Aug-20214.8 KiB

avatar.goH A D11-Aug-20211.9 KiB

avatar_test.goH A D11-Aug-20211.5 KiB

award_emojis.goH A D11-Aug-202117.1 KiB

boards.goH A D11-Aug-20219.9 KiB

branches.goH A D11-Aug-20217.3 KiB

branches_test.goH A D11-Aug-20212 KiB

broadcast_messages.goH A D11-Aug-20215.6 KiB

broadcast_messages_test.goH A D11-Aug-20216.2 KiB

ci_yml_templates.goH A D11-Aug-20212.5 KiB

client_options.goH A D11-Aug-20212.5 KiB

commits.goH A D11-Aug-202119.8 KiB

commits_test.goH A D11-Aug-20218.3 KiB

container_registry.goH A D11-Aug-20217.9 KiB

custom_attributes.goH A D11-Aug-20217.5 KiB

custom_attributes_test.goH A D11-Aug-20218.6 KiB

deploy_keys.goH A D11-Aug-20216.6 KiB

deploy_tokens.goH A D11-Aug-20217.3 KiB

deploy_tokens_test.goH A D11-Aug-20217.3 KiB

deployments.goH A D11-Aug-20216.8 KiB

discussions.goH A D11-Aug-202132.7 KiB

environments.goH A D11-Aug-20216.7 KiB

environments_test.goH A D11-Aug-20216.4 KiB

epic_issues.goH A D11-Aug-20214.4 KiB

epics.goH A D11-Aug-20219.5 KiB

epics_test.goH A D11-Aug-20214.3 KiB

event_parsing.goH A D11-Aug-20216.9 KiB

event_parsing_systemhook_test.goH A D11-Aug-20216.6 KiB

event_parsing_webhook_test.goH A D11-Aug-202112.5 KiB

event_systemhook_types.goH A D11-Aug-20214.8 KiB

event_webhook_types.goH A D11-Aug-202137.3 KiB

event_webhook_types_test.goH A D11-Aug-202111.2 KiB

events.goH A D11-Aug-20214.8 KiB

feature_flags.goH A D11-Aug-20212.4 KiB

feature_flags_test.goH A D11-Aug-20212.4 KiB

fixtures_test.goH A D11-Aug-20218 KiB

freeze_periods.goH A D11-Aug-20216 KiB

gitignore_templates.goH A D11-Aug-20212.5 KiB

gitlab.goH A D11-Aug-202125.7 KiB

gitlab_test.goH A D11-Aug-20214.7 KiB

go.modH A D11-Aug-2021510

go.sumH A D11-Aug-20214 KiB

group_badges.goH A D11-Aug-20216.6 KiB

group_boards.goH A D11-Aug-202110 KiB

group_clusters.goH A D11-Aug-20217.7 KiB

group_hooks.goH A D11-Aug-20218.2 KiB

group_hooks_test.goH A D11-Aug-20217.4 KiB

group_import_export.goH A D11-Aug-20214.5 KiB

group_import_export_test.goH A D11-Aug-20212.1 KiB

group_labels.goH A D11-Aug-20216.9 KiB

group_labels_test.goH A D11-Aug-20215.7 KiB

group_members.goH A D11-Aug-202110.9 KiB

group_members_test.goH A D11-Aug-20215.2 KiB

group_milestones.goH A D11-Aug-20219.7 KiB

group_variables.goH A D11-Aug-20216.4 KiB

group_variables_test.goH A D11-Aug-20214.4 KiB

group_wikis.goH A D11-Aug-20215.8 KiB

group_wikis_test.goH A D11-Aug-20213.8 KiB

groups.goH A D11-Aug-202129.2 KiB

groups_badges_test.goH A D11-Aug-20214 KiB

groups_test.goH A D11-Aug-20219.5 KiB

instance_clusters.goH A D11-Aug-20214.5 KiB

instance_variables.goH A D11-Aug-20215.8 KiB

invites.goH A D11-Aug-20215.4 KiB

invites_test.goH A D11-Aug-20214.3 KiB

issue_links.goH A D11-Aug-20213.7 KiB

issues.goH A D11-Aug-202129.2 KiB

issues_statistics.goH A D11-Aug-20218 KiB

issues_statistics_test.goH A D11-Aug-20213.8 KiB

issues_test.goH A D11-Aug-202119.7 KiB

jobs.goH A D11-Aug-202114.6 KiB

jobs_test.goH A D11-Aug-20214.6 KiB

keys.goH A D11-Aug-20211.7 KiB

keys_test.goH A D11-Aug-20213.2 KiB

labels.goH A D11-Aug-20219 KiB

labels_test.goH A D11-Aug-20215.5 KiB

license.goH A D11-Aug-20213.3 KiB

license_templates.goH A D11-Aug-20213.4 KiB

merge_request_approvals.goH A D11-Aug-202114.9 KiB

merge_request_approvals_test.goH A D11-Aug-202111.1 KiB

merge_requests.goH A D11-Aug-202137.5 KiB

merge_requests_test.goH A D11-Aug-20219 KiB

milestones.goH A D11-Aug-20218.4 KiB

namespaces.goH A D11-Aug-20213.5 KiB

notes.goH A D11-Aug-202120.1 KiB

notes_test.goH A D11-Aug-20212.2 KiB

notifications.goH A D11-Aug-20218.3 KiB

packages.goH A D11-Aug-20214.9 KiB

pages_domains.goH A D11-Aug-20216.5 KiB

pipeline_schedules.goH A D11-Aug-202111.1 KiB

pipeline_schedules_test.goH A D11-Aug-20211.3 KiB

pipeline_triggers.goH A D11-Aug-20217.5 KiB

pipeline_triggers_test.goH A D11-Aug-20211.3 KiB

pipelines.goH A D11-Aug-202111.7 KiB

pipelines_test.goH A D11-Aug-20217.7 KiB

project_access_tokens.goH A D11-Aug-20214.5 KiB

project_access_tokens_test.goH A D11-Aug-20213.9 KiB

project_badges.goH A D11-Aug-20216.8 KiB

project_clusters.goH A D11-Aug-20218.6 KiB

project_clusters_test.goH A D11-Aug-20219.5 KiB

project_import_export.goH A D11-Aug-20216.5 KiB

project_managed_licenses.goH A D11-Aug-20215.6 KiB

project_managed_licenses_test.goH A D11-Aug-20214.5 KiB

project_members.goH A D11-Aug-20217.3 KiB

project_mirror.goH A D11-Aug-20215 KiB

project_snippets.goH A D11-Aug-20216.4 KiB

project_variables.goH A D11-Aug-20216.5 KiB

projects.goH A D11-Aug-202180.8 KiB

projects_test.goH A D11-Aug-202128.6 KiB

protected_branches.goH A D11-Aug-20218.2 KiB

protected_branches_test.goH A D11-Aug-20215.6 KiB

protected_environments.goH A D11-Aug-20216.1 KiB

protected_environments_test.goH A D11-Aug-20214.1 KiB

protected_tags.goH A D11-Aug-20214.9 KiB

protected_tags_test.goH A D11-Aug-20213.8 KiB

releaselinks.goH A D11-Aug-20216 KiB

releaselinks_test.goH A D11-Aug-20215.8 KiB

releases.goH A D11-Aug-20216.9 KiB

releases_test.goH A D11-Aug-202112 KiB

repositories.goH A D11-Aug-20219.3 KiB

repository_files.goH A D11-Aug-202111.6 KiB

request_options.goH A D11-Aug-20211.3 KiB

resource_label_events.goH A D11-Aug-20216.6 KiB

resource_state_events.goH A D11-Aug-20214.6 KiB

runners.goH A D11-Aug-202115.4 KiB

runners_test.goH A D11-Aug-20219.1 KiB

search.goH A D11-Aug-202113.5 KiB

search_test.goH A D11-Aug-20212.8 KiB

services.goH A D11-Aug-202150.6 KiB

services_test.goH A D11-Aug-202115.2 KiB

settings.goH A D11-Aug-202140.9 KiB

settings_test.goH A D11-Aug-20211.8 KiB

sidekiq_metrics.goH A D11-Aug-20214.6 KiB

snippets.goH A D11-Aug-20216.9 KiB

strings.goH A D11-Aug-20212 KiB

system_hooks.goH A D11-Aug-20214.4 KiB

tags.goH A D11-Aug-20217.2 KiB

tags_test.goH A D11-Aug-20212.8 KiB

time_stats.goH A D11-Aug-20215.2 KiB

todos.goH A D11-Aug-20216.2 KiB

todos_test.goH A D11-Aug-20211.9 KiB

types.goH A D11-Aug-202116.9 KiB

types_test.goH A D11-Aug-20211.7 KiB

users.goH A D11-Aug-202134.6 KiB

users_test.goH A D11-Aug-20218 KiB

validate.goH A D11-Aug-20214 KiB

validate_test.goH A D11-Aug-20215.4 KiB

version.goH A D11-Aug-20211.6 KiB

version_test.goH A D11-Aug-20211.2 KiB

wikis.goH A D11-Aug-20215.5 KiB

README.md

1# go-gitlab
2
3A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way
4
5[![Build Status](https://github.com/xanzy/go-gitlab/workflows/Lint%20and%20Test/badge.svg)](https://github.com/xanzy/go-gitlab/actions?workflow=Lint%20and%20Test)
6[![Sourcegraph](https://sourcegraph.com/github.com/xanzy/go-gitlab/-/badge.svg)](https://sourcegraph.com/github.com/xanzy/go-gitlab?badge)
7[![GoDoc](https://godoc.org/github.com/xanzy/go-gitlab?status.svg)](https://godoc.org/github.com/xanzy/go-gitlab)
8[![Go Report Card](https://goreportcard.com/badge/github.com/xanzy/go-gitlab)](https://goreportcard.com/report/github.com/xanzy/go-gitlab)
9
10## NOTE
11
12Release v0.6.0 (released on 25-08-2017) no longer supports the older V3 Gitlab API. If
13you need V3 support, please use the `f-api-v3` branch. This release contains some backwards
14incompatible changes that were needed to fully support the V4 Gitlab API.
15
16## Coverage
17
18This API client package covers most of the existing Gitlab API calls and is updated regularly
19to add new and/or missing endpoints. Currently the following services are supported:
20
21- [x] Applications
22- [x] Award Emojis
23- [x] Branches
24- [x] Broadcast Messages
25- [x] Commits
26- [x] Container Registry
27- [x] Custom Attributes
28- [x] Deploy Keys
29- [x] Deployments
30- [ ] Discussions (threaded comments)
31- [x] Environments
32- [ ] Epic Issues
33- [ ] Epics
34- [x] Events
35- [x] Feature Flags
36- [ ] Geo Nodes
37- [x] GitLab CI Config Templates
38- [x] Gitignores Templates
39- [x] Group Access Requests
40- [x] Group Issue Boards
41- [x] Group Members
42- [x] Group Milestones
43- [x] Group Wikis
44- [x] Group-Level Variables
45- [x] Groups
46- [x] Instance Clusters
47- [x] Invites
48- [x] Issue Boards
49- [x] Issues
50- [x] Jobs
51- [x] Keys
52- [x] Labels
53- [x] License
54- [x] Merge Request Approvals
55- [x] Merge Requests
56- [x] Namespaces
57- [x] Notes (comments)
58- [x] Notification Settings
59- [x] Open Source License Templates
60- [x] Pages Domains
61- [x] Personal Access Tokens
62- [x] Pipeline Schedules
63- [x] Pipeline Triggers
64- [x] Pipelines
65- [x] Project Access Requests
66- [x] Project Badges
67- [x] Project Clusters
68- [x] Project Import/export
69- [x] Project Members
70- [x] Project Milestones
71- [x] Project Snippets
72- [x] Project-Level Variables
73- [x] Projects (including setting Webhooks)
74- [x] Protected Branches
75- [x] Protected Environments
76- [x] Protected Tags
77- [x] Repositories
78- [x] Repository Files
79- [x] Runners
80- [x] Search
81- [x] Services
82- [x] Settings
83- [x] Sidekiq Metrics
84- [x] System Hooks
85- [x] Tags
86- [x] Todos
87- [x] Users
88- [x] Validate CI Configuration
89- [x] Version
90- [x] Wikis
91
92## Usage
93
94```go
95import "github.com/xanzy/go-gitlab"
96```
97
98Construct a new GitLab client, then use the various services on the client to
99access different parts of the GitLab API. For example, to list all
100users:
101
102```go
103git, err := gitlab.NewClient("yourtokengoeshere")
104if err != nil {
105  log.Fatalf("Failed to create client: %v", err)
106}
107users, _, err := git.Users.ListUsers(&gitlab.ListUsersOptions{})
108```
109
110There are a few `With...` option functions that can be used to customize
111the API client. For example, to set a custom base URL:
112
113```go
114git, err := gitlab.NewClient("yourtokengoeshere", gitlab.WithBaseURL("https://git.mydomain.com/api/v4"))
115if err != nil {
116  log.Fatalf("Failed to create client: %v", err)
117}
118users, _, err := git.Users.ListUsers(&gitlab.ListUsersOptions{})
119```
120
121Some API methods have optional parameters that can be passed. For example,
122to list all projects for user "svanharmelen":
123
124```go
125git := gitlab.NewClient("yourtokengoeshere")
126opt := &ListProjectsOptions{Search: gitlab.String("svanharmelen")}
127projects, _, err := git.Projects.ListProjects(opt)
128```
129
130### Examples
131
132The [examples](https://github.com/xanzy/go-gitlab/tree/master/examples) directory
133contains a couple for clear examples, of which one is partially listed here as well:
134
135```go
136package main
137
138import (
139	"log"
140
141	"github.com/xanzy/go-gitlab"
142)
143
144func main() {
145	git, err := gitlab.NewClient("yourtokengoeshere")
146	if err != nil {
147		log.Fatalf("Failed to create client: %v", err)
148	}
149
150	// Create new project
151	p := &gitlab.CreateProjectOptions{
152		Name:                 gitlab.String("My Project"),
153		Description:          gitlab.String("Just a test project to play with"),
154		MergeRequestsEnabled: gitlab.Bool(true),
155		SnippetsEnabled:      gitlab.Bool(true),
156		Visibility:           gitlab.Visibility(gitlab.PublicVisibility),
157	}
158	project, _, err := git.Projects.CreateProject(p)
159	if err != nil {
160		log.Fatal(err)
161	}
162
163	// Add a new snippet
164	s := &gitlab.CreateProjectSnippetOptions{
165		Title:           gitlab.String("Dummy Snippet"),
166		FileName:        gitlab.String("snippet.go"),
167		Content:         gitlab.String("package main...."),
168		Visibility:      gitlab.Visibility(gitlab.PublicVisibility),
169	}
170	_, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
171	if err != nil {
172		log.Fatal(err)
173	}
174}
175```
176
177For complete usage of go-gitlab, see the full [package docs](https://godoc.org/github.com/xanzy/go-gitlab).
178
179## ToDo
180
181- The biggest thing this package still needs is tests :disappointed:
182
183## Issues
184
185- If you have an issue: report it on the [issue tracker](https://github.com/xanzy/go-gitlab/issues)
186
187## Author
188
189Sander van Harmelen (<sander@vanharmelen.nl>)
190
191## License
192
193Licensed 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>
194