-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab_api.go
42 lines (33 loc) · 1.83 KB
/
gitlab_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"github.com/xanzy/go-gitlab"
)
type GitlabWrapper interface {
GetMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
CurrentUser(options ...gitlab.RequestOptionFunc) (*gitlab.User, *gitlab.Response, error)
GetConfiguration(pid interface{}, mr int, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error)
UpdateMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
}
type Gitlab struct {
client *gitlab.Client
}
func (g *Gitlab) GetMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
return g.client.MergeRequests.GetMergeRequest(pid, mergeRequest, opt)
}
func (g *Gitlab) CurrentUser(options ...gitlab.RequestOptionFunc) (*gitlab.User, *gitlab.Response, error) {
return g.client.Users.CurrentUser()
}
func (g *Gitlab) GetConfiguration(pid interface{}, mr int, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error) {
return g.client.MergeRequestApprovals.GetConfiguration(pid, mr)
}
func (g *Gitlab) UpdateMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
return g.client.MergeRequests.UpdateMergeRequest(pid, mergeRequest, opt)
}
func newGitlabClient(host string, token string) (*Gitlab, error) {
c, err := gitlab.NewClient(token, gitlab.WithBaseURL(fmt.Sprintf("https://%s/api/v4", host)))
if err != nil {
return nil, err
}
return &Gitlab{client: c}, nil
}