Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api to v4 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Folders
_obj
_test
.idea

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
26 changes: 24 additions & 2 deletions api/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
language: go

go:
- 1.4.3
- 1.5.1
- 1.9.x
- 1.10.x
- 1.11.x
- master

stages:
- lint
- test

jobs:
include:
- stage: lint
script:
- go get golang.org/x/lint/golint
- golint -set_exit_status
- go vet -v
- stage: test
script:
- go test -v

matrix:
allow_failures:
- go: master
fast_finish: true
23 changes: 22 additions & 1 deletion api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
go-github CHANGELOG
===================

0.6.0
-----
- Add support for the V4 Gitlab API. This means the older V3 API is no longer fully supported
with this version. If you still need that version, please use the `f-api-v3` branch.

0.4.0
-----
- Add support to use [`sudo`](https://docs.gitlab.com/ce/api/README.html#sudo) for all API calls.
- Add support for the Notification Settings API.
- Add support for the Time Tracking API.
- Make sure that the error response correctly outputs any returned errors.
- And a reasonable number of smaller enhanchements and bugfixes.

0.3.0
-----
- Moved the tags related API calls to their own service, following the Gitlab API structure.

0.2.0
-----
- Convert all Option structs to use pointers for their fields.

0.1.0
-----
- Initial release
- Initial release.
118 changes: 86 additions & 32 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,87 @@

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

**Documentation:** [![GoDoc](https://godoc.org/github.com/xanzy/go-gitlab?status.svg)](https://godoc.org/github.com/xanzy/go-gitlab)
**Build Status:** [![Build Status](https://travis-ci.org/xanzy/go-gitlab.svg?branch=master)](https://travis-ci.org/xanzy/go-gitlab)
[![Build Status](https://travis-ci.org/xanzy/go-gitlab.svg?branch=master)](https://travis-ci.org/xanzy/go-gitlab)
[![GitHub license](https://img.shields.io/github/license/xanzy/go-gitlab.svg)](https://github.com/xanzy/go-gitlab/blob/master/LICENSE)
[![Sourcegraph](https://sourcegraph.com/github.com/xanzy/go-gitlab/-/badge.svg)](https://sourcegraph.com/github.com/xanzy/go-gitlab?badge)
[![GoDoc](https://godoc.org/github.com/xanzy/go-gitlab?status.svg)](https://godoc.org/github.com/xanzy/go-gitlab)
[![Go Report Card](https://goreportcard.com/badge/github.com/xanzy/go-gitlab)](https://goreportcard.com/report/github.com/xanzy/go-gitlab)
[![GitHub issues](https://img.shields.io/github/issues/xanzy/go-gitlab.svg)](https://github.com/xanzy/go-gitlab/issues)

## 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:
This API client package covers most of the existing Gitlab API calls and is updated regularly
to add new and/or missing endpoints. Currently the following services are supported:

- [x] Users
- [x] Session
- [x] Projects (including setting Webhooks)
- [x] Project Snippets
- [x] Services
- [x] Repositories
- [x] Repository Files
- [x] Commits
- [ ] Discussions (threaded comments)
- [ ] Epic Issues
- [ ] Epics
- [ ] Geo Nodes
- [ ] Project import/export
- [x] Award Emojis
- [x] Branches
- [x] Merge Requests
- [x] Issues
- [x] Labels
- [x] Milestones
- [x] Notes (comments)
- [x] Broadcast Messages
- [x] Commits
- [x] Custom Attributes
- [x] Deploy Keys
- [x] System Hooks
- [x] Deployments
- [x] Environments
- [x] Events
- [x] Feature flags
- [x] GitLab CI Config templates
- [x] Gitignores templates
- [x] Group Access Requests
- [x] Group Issue Boards
- [x] Group Members
- [x] Group Milestones
- [x] Group-level Variables
- [x] Groups
- [x] Issue Boards
- [x] Issues
- [x] Jobs
- [x] Keys
- [x] Labels
- [x] License
- [x] Merge Request Approvals
- [x] Merge Requests
- [x] Namespaces
- [x] Notes (comments)
- [x] Notification settings
- [x] Open source license templates
- [x] Pages Domains
- [x] Pipeline Schedules
- [x] Pipeline Triggers
- [x] Pipelines
- [x] Project Access Requests
- [x] Project Clusters
- [x] Project Members
- [x] Project Milestones
- [x] Project Snippets
- [x] Project badges
- [x] Project-level Variables
- [x] Projects (including setting Webhooks)
- [x] Protected Branches
- [x] Protected Tags
- [x] Repositories
- [x] Repository Files
- [x] Runners
- [x] Search
- [x] Services
- [x] Settings
- [x] Sidekiq metrics
- [x] System Hooks
- [x] Tags
- [x] Todos
- [x] Users
- [x] Validate CI configuration
- [x] Version
- [x] Wikis

## Usage

Expand All @@ -42,16 +96,17 @@ users:

```go
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":

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

### Examples
Expand All @@ -73,30 +128,29 @@ func main() {

// Create new project
p := &gitlab.CreateProjectOptions{
Name: "My Project",
Description: "Just a test project to play with",
MergeRequestsEnabled: true,
SnippetsEnabled: true,
VisibilityLevel: gitlab.PublicVisibility,
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.Visibility(gitlab.PublicVisibility),
}
project, _, err := git.Projects.CreateProject(p)
if err != nil {
log.Fatal(err)
}

// Add a new snippet
s := &gitlab.CreateSnippetOptions{
Title: "Dummy Snippet",
FileName: "snippet.go",
Code: "package main....",
VisibilityLevel: gitlab.PublicVisibility,
s := &gitlab.CreateProjectSnippetOptions{
Title: gitlab.String("Dummy Snippet"),
FileName: gitlab.String("snippet.go"),
Code: gitlab.String("package main...."),
Visibility: gitlab.Visibility(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](https://godoc.org/github.com/xanzy/go-gitlab).
Expand Down
Loading