1
0
Fork 0
forked from forgejo/forgejo

Vendor Update (#14696)

* github.com/yuin/goldmark v1.3.1 -> v1.3.2

* github.com/xanzy/go-gitlab v0.42.0 -> v0.44.0

* github.com/prometheus/client_golang v1.8.0 -> v1.9.0

* github.com/minio/minio-go v7.0.7 -> v7.0.9

* github.com/lafriks/xormstore v1.3.2 -> v1.4.0

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2021-02-17 04:47:24 +01:00 committed by GitHub
parent dc707aea09
commit fe628d8406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 3348 additions and 1312 deletions

View file

@ -1,23 +0,0 @@
language: go
arch:
- amd64
- ppc64le
go:
- 1.13.x
- 1.14.x
- 1.x
- master
before_install:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.35.0/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.0
script:
- golangci-lint run
- go test -v
matrix:
allow_failures:
- go: master
fast_finish: true

View file

@ -1,27 +0,0 @@
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.

View file

@ -178,7 +178,7 @@
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -2,12 +2,10 @@
A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way
[![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)
[![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)
[![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
@ -42,9 +40,11 @@ to add new and/or missing endpoints. Currently the following services are suppor
- [x] Group Issue Boards
- [x] Group Members
- [x] Group Milestones
- [x] Group Wikis
- [x] Group-Level Variables
- [x] Groups
- [x] Instance Clusters
- [x] Invites
- [x] Issue Boards
- [x] Issues
- [x] Jobs
@ -71,6 +71,7 @@ to add new and/or missing endpoints. Currently the following services are suppor
- [x] Project-Level Variables
- [x] Projects (including setting Webhooks)
- [x] Protected Branches
- [x] Protected Environments
- [x] Protected Tags
- [x] Repositories
- [x] Repository Files

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -46,7 +63,7 @@ func (s *AccessRequestsService) ListProjectAccessRequests(pid interface{}, opt *
}
u := fmt.Sprintf("projects/%s/access_requests", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -72,7 +89,7 @@ func (s *AccessRequestsService) ListGroupAccessRequests(gid interface{}, opt *Li
}
u := fmt.Sprintf("groups/%s/access_requests", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -98,7 +115,7 @@ func (s *AccessRequestsService) RequestProjectAccess(pid interface{}, options ..
}
u := fmt.Sprintf("projects/%s/access_requests", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -124,7 +141,7 @@ func (s *AccessRequestsService) RequestGroupAccess(gid interface{}, options ...R
}
u := fmt.Sprintf("groups/%s/access_requests", pathEscape(group))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -158,7 +175,7 @@ func (s *AccessRequestsService) ApproveProjectAccessRequest(pid interface{}, use
}
u := fmt.Sprintf("projects/%s/access_requests/%d/approve", pathEscape(project), user)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -183,7 +200,7 @@ func (s *AccessRequestsService) ApproveGroupAccessRequest(gid interface{}, user
}
u := fmt.Sprintf("groups/%s/access_requests/%d/approve", pathEscape(group), user)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -208,7 +225,7 @@ func (s *AccessRequestsService) DenyProjectAccessRequest(pid interface{}, user i
}
u := fmt.Sprintf("projects/%s/access_requests/%d", pathEscape(project), user)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -227,7 +244,7 @@ func (s *AccessRequestsService) DenyGroupAccessRequest(gid interface{}, user int
}
u := fmt.Sprintf("groups/%s/access_requests/%d", pathEscape(group), user)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,7 +16,10 @@
package gitlab
import "fmt"
import (
"fmt"
"net/http"
)
// ApplicationsService handles communication with administrables applications
// of the Gitlab API.
@ -51,7 +54,7 @@ type CreateApplicationOptions struct {
//
// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#create-an-application
func (s *ApplicationsService) CreateApplication(opt *CreateApplicationOptions, options ...RequestOptionFunc) (*Application, *Response, error) {
req, err := s.client.NewRequest("POST", "applications", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "applications", opt, options)
if err != nil {
return nil, nil, err
}
@ -73,7 +76,7 @@ type ListApplicationsOptions ListOptions
//
// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#list-all-applications
func (s *ApplicationsService) ListApplications(opt *ListApplicationsOptions, options ...RequestOptionFunc) ([]*Application, *Response, error) {
req, err := s.client.NewRequest("GET", "applications", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "applications", opt, options)
if err != nil {
return nil, nil, err
}
@ -94,7 +97,7 @@ func (s *ApplicationsService) ListApplications(opt *ListApplicationsOptions, opt
func (s *ApplicationsService) DeleteApplication(application int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("applications/%d", application)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

158
vendor/github.com/xanzy/go-gitlab/audit_events.go generated vendored Normal file
View file

@ -0,0 +1,158 @@
package gitlab
import (
"fmt"
"net/http"
"time"
)
// AuditEvent represents an audit event for a group or project.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type AuditEvent struct {
ID int `json:"id"`
AuthorID int `json:"author_id"`
EntityID int `json:"entity_id"`
EntityType string `json:"entity_type"`
Details AuditEventDetails `json:"details"`
CreatedAt *time.Time `json:"created_at"`
}
// AuditEventDetails represents the details portion of an audit event for
// a group or project. The exact fields that are returned for an audit event
// depend on the action being recorded.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type AuditEventDetails struct {
With string `json:"with"`
Add string `json:"add"`
As string `json:"as"`
Change string `json:"change"`
From string `json:"from"`
To string `json:"to"`
Remove string `json:"remove"`
CustomMessage string `json:"custom_message"`
AuthorName string `json:"author_name"`
TargetID interface{} `json:"target_id"`
TargetType string `json:"target_type"`
TargetDetails string `json:"target_details"`
IPAddress string `json:"ip_address"`
EntityPath string `json:"entity_path"`
}
// AuditEventsService handles communication with the project/group audit
// event related methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type AuditEventsService struct {
client *Client
}
// ListAuditEventsOptions represents the available ListProjectAuditEvents()
// or ListGroupAuditEvents() options.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type ListAuditEventsOptions struct {
ListOptions
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
}
// ListGroupAuditEvents gets a list of audit events for the specified group
// viewable by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) ListGroupAuditEvents(gid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/audit_events", pathEscape(group))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var aes []*AuditEvent
resp, err := s.client.Do(req, &aes)
if err != nil {
return nil, resp, err
}
return aes, resp, err
}
// GetGroupAuditEvent gets a specific group audit event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetGroupAuditEvent(gid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/audit_events/%d", pathEscape(group), event)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
ae := new(AuditEvent)
resp, err := s.client.Do(req, ae)
if err != nil {
return nil, resp, err
}
return ae, resp, err
}
// ListProjectAuditEvents gets a list of audit events for the specified project
// viewable by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) ListProjectAuditEvents(pid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events", pathEscape(project))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var aes []*AuditEvent
resp, err := s.client.Do(req, &aes)
if err != nil {
return nil, resp, err
}
return aes, resp, err
}
// GetProjectAuditEvent gets a specific project audit event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetProjectAuditEvent(pid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events/%d", pathEscape(project), event)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
ae := new(AuditEvent)
resp, err := s.client.Do(req, ae)
if err != nil {
return nil, resp, err
}
return ae, resp, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Arkbriar
// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -97,7 +98,7 @@ func (s *AwardEmojiService) listAwardEmoji(pid interface{}, resource string, res
resourceID,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -147,7 +148,7 @@ func (s *AwardEmojiService) getAwardEmoji(pid interface{}, resource string, reso
awardID,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -205,7 +206,7 @@ func (s *AwardEmojiService) createAwardEmoji(pid interface{}, resource string, r
resourceID,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -255,7 +256,7 @@ func (s *AwardEmojiService) deleteAwardEmoji(pid interface{}, resource string, r
u := fmt.Sprintf("projects/%s/%s/%d/award_emoji/%d", pathEscape(project), resource,
resourceID, awardID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -297,7 +298,7 @@ func (s *AwardEmojiService) listAwardEmojiOnNote(pid interface{}, resources stri
u := fmt.Sprintf("projects/%s/%s/%d/notes/%d/award_emoji", pathEscape(project), resources,
ressourceID, noteID)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -350,7 +351,7 @@ func (s *AwardEmojiService) getSingleNoteAwardEmoji(pid interface{}, ressource s
awardID,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -405,7 +406,7 @@ func (s *AwardEmojiService) createAwardEmojiOnNote(pid interface{}, resource str
noteID,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -458,7 +459,7 @@ func (s *AwardEmojiService) deleteAwardEmojiOnNote(pid interface{}, resource str
awardID,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2015, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// IssueBoardsService handles communication with the issue board related
@ -73,7 +74,7 @@ func (s *IssueBoardsService) CreateIssueBoard(pid interface{}, opt *CreateIssueB
}
u := fmt.Sprintf("projects/%s/boards", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -108,7 +109,7 @@ func (s *IssueBoardsService) UpdateIssueBoard(pid interface{}, board int, opt *U
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -132,7 +133,7 @@ func (s *IssueBoardsService) DeleteIssueBoard(pid interface{}, board int, option
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -155,7 +156,7 @@ func (s *IssueBoardsService) ListIssueBoards(pid interface{}, opt *ListIssueBoar
}
u := fmt.Sprintf("projects/%s/boards", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -179,7 +180,7 @@ func (s *IssueBoardsService) GetIssueBoard(pid interface{}, board int, options .
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -209,7 +210,7 @@ func (s *IssueBoardsService) GetIssueBoardLists(pid interface{}, board int, opt
}
u := fmt.Sprintf("projects/%s/boards/%d/lists", pathEscape(project), board)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -237,7 +238,7 @@ func (s *IssueBoardsService) GetIssueBoardList(pid interface{}, board, list int,
list,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -269,7 +270,7 @@ func (s *IssueBoardsService) CreateIssueBoardList(pid interface{}, board int, op
}
u := fmt.Sprintf("projects/%s/boards/%d/lists", pathEscape(project), board)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -305,7 +306,7 @@ func (s *IssueBoardsService) UpdateIssueBoardList(pid interface{}, board, list i
list,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -335,7 +336,7 @@ func (s *IssueBoardsService) DeleteIssueBoardList(pid interface{}, board, list i
list,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -69,7 +70,7 @@ func (s *BranchesService) ListBranches(pid interface{}, opts *ListBranchesOption
}
u := fmt.Sprintf("projects/%s/repository/branches", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -94,7 +95,7 @@ func (s *BranchesService) GetBranch(pid interface{}, branch string, options ...R
}
u := fmt.Sprintf("projects/%s/repository/branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -130,7 +131,7 @@ func (s *BranchesService) ProtectBranch(pid interface{}, branch string, opts *Pr
}
u := fmt.Sprintf("projects/%s/repository/branches/%s/protect", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("PUT", u, opts, options)
req, err := s.client.NewRequest(http.MethodPut, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -157,7 +158,7 @@ func (s *BranchesService) UnprotectBranch(pid interface{}, branch string, option
}
u := fmt.Sprintf("projects/%s/repository/branches/%s/unprotect", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("PUT", u, nil, options)
req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -191,7 +192,7 @@ func (s *BranchesService) CreateBranch(pid interface{}, opt *CreateBranchOptions
}
u := fmt.Sprintf("projects/%s/repository/branches", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -216,7 +217,7 @@ func (s *BranchesService) DeleteBranch(pid interface{}, branch string, options .
}
u := fmt.Sprintf("projects/%s/repository/branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -235,7 +236,7 @@ func (s *BranchesService) DeleteMergedBranches(pid interface{}, options ...Reque
}
u := fmt.Sprintf("projects/%s/repository/merged_branches", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -55,7 +56,7 @@ type ListBroadcastMessagesOptions ListOptions
// GitLab API docs:
// https://docs.gitlab.com/ce/api/broadcast_messages.html#get-all-broadcast-messages
func (s *BroadcastMessagesService) ListBroadcastMessages(opt *ListBroadcastMessagesOptions, options ...RequestOptionFunc) ([]*BroadcastMessage, *Response, error) {
req, err := s.client.NewRequest("GET", "broadcast_messages", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "broadcast_messages", opt, options)
if err != nil {
return nil, nil, err
}
@ -76,7 +77,7 @@ func (s *BroadcastMessagesService) ListBroadcastMessages(opt *ListBroadcastMessa
func (s *BroadcastMessagesService) GetBroadcastMessage(broadcast int, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -108,7 +109,7 @@ type CreateBroadcastMessageOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/broadcast_messages.html#create-a-broadcast-message
func (s *BroadcastMessagesService) CreateBroadcastMessage(opt *CreateBroadcastMessageOptions, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
req, err := s.client.NewRequest("POST", "broadcast_messages", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "broadcast_messages", opt, options)
if err != nil {
return nil, nil, err
}
@ -142,7 +143,7 @@ type UpdateBroadcastMessageOptions struct {
func (s *BroadcastMessagesService) UpdateBroadcastMessage(broadcast int, opt *UpdateBroadcastMessageOptions, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -163,7 +164,7 @@ func (s *BroadcastMessagesService) UpdateBroadcastMessage(broadcast int, opt *Up
func (s *BroadcastMessagesService) DeleteBroadcastMessage(broadcast int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// CIYMLTemplatesService handles communication with the gitlab
@ -33,7 +50,7 @@ type ListCIYMLTemplatesOptions ListOptions
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/gitlab_ci_ymls.html#list-gitlab-ci-yml-templates
func (s *CIYMLTemplatesService) ListAllTemplates(opt *ListCIYMLTemplatesOptions, options ...RequestOptionFunc) ([]*CIYMLTemplate, *Response, error) {
req, err := s.client.NewRequest("GET", "templates/gitlab_ci_ymls", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "templates/gitlab_ci_ymls", opt, options)
if err != nil {
return nil, nil, err
}
@ -54,7 +71,7 @@ func (s *CIYMLTemplatesService) ListAllTemplates(opt *ListCIYMLTemplatesOptions,
func (s *CIYMLTemplatesService) GetTemplate(key string, options ...RequestOptionFunc) (*CIYMLTemplate, *Response, error) {
u := fmt.Sprintf("templates/gitlab_ci_ymls/%s", pathEscape(key))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,3 +1,19 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
"time"
)
@ -90,7 +91,7 @@ func (s *CommitsService) ListCommits(pid interface{}, opt *ListCommitsOptions, o
}
u := fmt.Sprintf("projects/%s/repository/commits", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -133,7 +134,7 @@ func (s *CommitsService) GetCommitRefs(pid interface{}, sha string, opt *GetComm
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/refs", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -161,7 +162,7 @@ func (s *CommitsService) GetCommit(pid interface{}, sha string, options ...Reque
}
u := fmt.Sprintf("projects/%s/repository/commits/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -196,13 +197,13 @@ type CreateCommitOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
type CommitActionOptions struct {
Action *FileAction `url:"action,omitempty" json:"action,omitempty"`
FilePath *string `url:"file_path,omitempty" json:"file_path,omitempty"`
PreviousPath *string `url:"previous_path,omitempty" json:"previous_path,omitempty"`
Content *string `url:"content,omitempty" json:"content,omitempty"`
Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
LastCommitID *string `url:"last_commit_id,omitempty" json:"last_commit_id,omitempty"`
ExecuteFilemode *bool `url:"execute_filemode,omitempty" json:"execute_filemode,omitempty"`
Action *FileActionValue `url:"action,omitempty" json:"action,omitempty"`
FilePath *string `url:"file_path,omitempty" json:"file_path,omitempty"`
PreviousPath *string `url:"previous_path,omitempty" json:"previous_path,omitempty"`
Content *string `url:"content,omitempty" json:"content,omitempty"`
Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
LastCommitID *string `url:"last_commit_id,omitempty" json:"last_commit_id,omitempty"`
ExecuteFilemode *bool `url:"execute_filemode,omitempty" json:"execute_filemode,omitempty"`
}
// CreateCommit creates a commit with multiple files and actions.
@ -215,7 +216,7 @@ func (s *CommitsService) CreateCommit(pid interface{}, opt *CreateCommitOptions,
}
u := fmt.Sprintf("projects/%s/repository/commits", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -264,7 +265,7 @@ func (s *CommitsService) GetCommitDiff(pid interface{}, sha string, opt *GetComm
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/diff", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -321,7 +322,7 @@ func (s *CommitsService) GetCommitComments(pid interface{}, sha string, opt *Get
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -360,7 +361,7 @@ func (s *CommitsService) PostCommitComment(pid interface{}, sha string, opt *Pos
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -413,7 +414,7 @@ func (s *CommitsService) GetCommitStatuses(pid interface{}, sha string, opt *Get
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/statuses", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -451,7 +452,7 @@ func (s *CommitsService) SetCommitStatus(pid interface{}, sha string, opt *SetCo
}
u := fmt.Sprintf("projects/%s/statuses/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -476,7 +477,7 @@ func (s *CommitsService) GetMergeRequestsByCommit(pid interface{}, sha string, o
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/merge_requests", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -507,7 +508,7 @@ func (s *CommitsService) CherryPickCommit(pid interface{}, sha string, opt *Cher
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/cherry_pick", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -538,7 +539,7 @@ func (s *CommitsService) RevertCommit(pid interface{}, sha string, opt *RevertCo
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/revert", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -575,7 +576,7 @@ func (s *CommitsService) GetGPGSiganature(pid interface{}, sha string, options .
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// CustomAttributesService handles communication with the group, project and
@ -46,7 +63,7 @@ func (s *CustomAttributesService) ListCustomProjectAttributes(project int, optio
func (s *CustomAttributesService) listCustomAttributes(resource string, id int, options ...RequestOptionFunc) ([]*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes", resource, id)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -85,7 +102,7 @@ func (s *CustomAttributesService) GetCustomProjectAttribute(project int, key str
func (s *CustomAttributesService) getCustomAttribute(resource string, id int, key string, options ...RequestOptionFunc) (*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, key)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -124,7 +141,7 @@ func (s *CustomAttributesService) SetCustomProjectAttribute(project int, c Custo
func (s *CustomAttributesService) setCustomAttribute(resource string, id int, c CustomAttribute, options ...RequestOptionFunc) (*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, c.Key)
req, err := s.client.NewRequest("PUT", u, c, options)
req, err := s.client.NewRequest(http.MethodPut, u, c, options)
if err != nil {
return nil, nil, err
}
@ -163,7 +180,7 @@ func (s *CustomAttributesService) DeleteCustomProjectAttribute(project int, key
func (s *CustomAttributesService) deleteCustomAttribute(resource string, id int, key string, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, key)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -47,7 +48,7 @@ func (k DeployKey) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_keys.html#list-all-deploy-keys
func (s *DeployKeysService) ListAllDeployKeys(options ...RequestOptionFunc) ([]*DeployKey, *Response, error) {
req, err := s.client.NewRequest("GET", "deploy_keys", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "deploy_keys", nil, options)
if err != nil {
return nil, nil, err
}
@ -79,7 +80,7 @@ func (s *DeployKeysService) ListProjectDeployKeys(pid interface{}, opt *ListProj
}
u := fmt.Sprintf("projects/%s/deploy_keys", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -104,7 +105,7 @@ func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -141,7 +142,7 @@ func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptio
}
u := fmt.Sprintf("projects/%s/deploy_keys", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -166,7 +167,7 @@ func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, opti
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -185,7 +186,7 @@ func (s *DeployKeysService) EnableDeployKey(pid interface{}, deployKey int, opti
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d/enable", pathEscape(project), deployKey)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -219,7 +220,7 @@ func (s *DeployKeysService) UpdateDeployKey(pid interface{}, deployKey int, opt
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -32,7 +49,7 @@ func (k DeployToken) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_tokens.html#list-all-deploy-tokens
func (s *DeployTokensService) ListAllDeployTokens(options ...RequestOptionFunc) ([]*DeployToken, *Response, error) {
req, err := s.client.NewRequest("GET", "deploy_tokens", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "deploy_tokens", nil, options)
if err != nil {
return nil, nil, err
}
@ -64,7 +81,7 @@ func (s *DeployTokensService) ListProjectDeployTokens(pid interface{}, opt *List
}
u := fmt.Sprintf("projects/%s/deploy_tokens", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -100,7 +117,7 @@ func (s *DeployTokensService) CreateProjectDeployToken(pid interface{}, opt *Cre
}
u := fmt.Sprintf("projects/%s/deploy_tokens", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -125,7 +142,7 @@ func (s *DeployTokensService) DeleteProjectDeployToken(pid interface{}, deployTo
}
u := fmt.Sprintf("projects/%s/deploy_tokens/%d", pathEscape(project), deployToken)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -151,7 +168,7 @@ func (s *DeployTokensService) ListGroupDeployTokens(gid interface{}, opt *ListGr
}
u := fmt.Sprintf("groups/%s/deploy_tokens", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -187,7 +204,7 @@ func (s *DeployTokensService) CreateGroupDeployToken(gid interface{}, opt *Creat
}
u := fmt.Sprintf("groups/%s/deploy_tokens", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -212,7 +229,7 @@ func (s *DeployTokensService) DeleteGroupDeployToken(gid interface{}, deployToke
}
u := fmt.Sprintf("groups/%s/deploy_tokens/%d", pathEscape(group), deployToken)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -89,7 +90,7 @@ func (s *DeploymentsService) ListProjectDeployments(pid interface{}, opts *ListP
}
u := fmt.Sprintf("projects/%s/deployments", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -113,7 +114,7 @@ func (s *DeploymentsService) GetProjectDeployment(pid interface{}, deployment in
}
u := fmt.Sprintf("projects/%s/deployments/%d", pathEscape(project), deployment)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -149,7 +150,7 @@ func (s *DeploymentsService) CreateProjectDeployment(pid interface{}, opt *Creat
}
u := fmt.Sprintf("projects/%s/deployments", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -181,7 +182,7 @@ func (s *DeploymentsService) UpdateProjectDeployment(pid interface{}, deployment
}
u := fmt.Sprintf("projects/%s/deployments/%d", pathEscape(project), deployment)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -61,7 +62,7 @@ func (s *DiscussionsService) ListIssueDiscussions(pid interface{}, issue int, op
}
u := fmt.Sprintf("projects/%s/issues/%d/discussions", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -90,7 +91,7 @@ func (s *DiscussionsService) GetIssueDiscussion(pid interface{}, issue int, disc
discussion,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -125,7 +126,7 @@ func (s *DiscussionsService) CreateIssueDiscussion(pid interface{}, issue int, o
}
u := fmt.Sprintf("projects/%s/issues/%d/discussions", pathEscape(project), issue)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -164,7 +165,7 @@ func (s *DiscussionsService) AddIssueDiscussionNote(pid interface{}, issue int,
discussion,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -204,7 +205,7 @@ func (s *DiscussionsService) UpdateIssueDiscussionNote(pid interface{}, issue in
note,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -234,7 +235,7 @@ func (s *DiscussionsService) DeleteIssueDiscussionNote(pid interface{}, issue in
note,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -261,7 +262,7 @@ func (s *DiscussionsService) ListSnippetDiscussions(pid interface{}, snippet int
}
u := fmt.Sprintf("projects/%s/snippets/%d/discussions", pathEscape(project), snippet)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -290,7 +291,7 @@ func (s *DiscussionsService) GetSnippetDiscussion(pid interface{}, snippet int,
discussion,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -326,7 +327,7 @@ func (s *DiscussionsService) CreateSnippetDiscussion(pid interface{}, snippet in
}
u := fmt.Sprintf("projects/%s/snippets/%d/discussions", pathEscape(project), snippet)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -366,7 +367,7 @@ func (s *DiscussionsService) AddSnippetDiscussionNote(pid interface{}, snippet i
discussion,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -406,7 +407,7 @@ func (s *DiscussionsService) UpdateSnippetDiscussionNote(pid interface{}, snippe
note,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -436,7 +437,7 @@ func (s *DiscussionsService) DeleteSnippetDiscussionNote(pid interface{}, snippe
note,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -466,7 +467,7 @@ func (s *DiscussionsService) ListGroupEpicDiscussions(gid interface{}, epic int,
epic,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -495,7 +496,7 @@ func (s *DiscussionsService) GetEpicDiscussion(gid interface{}, epic int, discus
discussion,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -534,7 +535,7 @@ func (s *DiscussionsService) CreateEpicDiscussion(gid interface{}, epic int, opt
epic,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -573,7 +574,7 @@ func (s *DiscussionsService) AddEpicDiscussionNote(gid interface{}, epic int, di
discussion,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -613,7 +614,7 @@ func (s *DiscussionsService) UpdateEpicDiscussionNote(gid interface{}, epic int,
note,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -643,7 +644,7 @@ func (s *DiscussionsService) DeleteEpicDiscussionNote(gid interface{}, epic int,
note,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -673,7 +674,7 @@ func (s *DiscussionsService) ListMergeRequestDiscussions(pid interface{}, mergeR
mergeRequest,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -703,7 +704,7 @@ func (s *DiscussionsService) GetMergeRequestDiscussion(pid interface{}, mergeReq
discussion,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -743,7 +744,7 @@ func (s *DiscussionsService) CreateMergeRequestDiscussion(pid interface{}, merge
mergeRequest,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -782,7 +783,7 @@ func (s *DiscussionsService) ResolveMergeRequestDiscussion(pid interface{}, merg
discussion,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -822,7 +823,7 @@ func (s *DiscussionsService) AddMergeRequestDiscussionNote(pid interface{}, merg
discussion,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -864,7 +865,7 @@ func (s *DiscussionsService) UpdateMergeRequestDiscussionNote(pid interface{}, m
note,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -895,7 +896,7 @@ func (s *DiscussionsService) DeleteMergeRequestDiscussionNote(pid interface{}, m
note,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -925,7 +926,7 @@ func (s *DiscussionsService) ListCommitDiscussions(pid interface{}, commit strin
commit,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -955,7 +956,7 @@ func (s *DiscussionsService) GetCommitDiscussion(pid interface{}, commit string,
discussion,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -994,7 +995,7 @@ func (s *DiscussionsService) CreateCommitDiscussion(pid interface{}, commit stri
commit,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1033,7 +1034,7 @@ func (s *DiscussionsService) AddCommitDiscussionNote(pid interface{}, commit str
discussion,
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1073,7 +1074,7 @@ func (s *DiscussionsService) UpdateCommitDiscussionNote(pid interface{}, commit
note,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1103,7 +1104,7 @@ func (s *DiscussionsService) DeleteCommitDiscussionNote(pid interface{}, commit
note,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// EnvironmentsService handles communication with the environment related methods
@ -63,7 +64,7 @@ func (s *EnvironmentsService) ListEnvironments(pid interface{}, opts *ListEnviro
}
u := fmt.Sprintf("projects/%s/environments", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -88,7 +89,7 @@ func (s *EnvironmentsService) GetEnvironment(pid interface{}, environment int, o
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -125,7 +126,7 @@ func (s *EnvironmentsService) CreateEnvironment(pid interface{}, opt *CreateEnvi
}
u := fmt.Sprintf("projects/%s/environments", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -159,7 +160,7 @@ func (s *EnvironmentsService) EditEnvironment(pid interface{}, environment int,
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -184,7 +185,7 @@ func (s *EnvironmentsService) DeleteEnvironment(pid interface{}, environment int
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -203,7 +204,7 @@ func (s *EnvironmentsService) StopEnvironment(pid interface{}, environmentID int
}
u := fmt.Sprintf("projects/%s/environments/%d/stop", pathEscape(project), environmentID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,6 +1,25 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import "fmt"
import (
"fmt"
"net/http"
)
// EpicIssuesService handles communication with the epic issue related methods
// of the GitLab API.
@ -31,7 +50,7 @@ func (s *EpicIssuesService) ListEpicIssues(gid interface{}, epic int, opt *ListO
}
u := fmt.Sprintf("groups/%s/epics/%d/issues", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -56,7 +75,7 @@ func (s *EpicIssuesService) AssignEpicIssue(gid interface{}, epic, issue int, op
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, issue)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -81,7 +100,7 @@ func (s *EpicIssuesService) RemoveEpicIssue(gid interface{}, epic, epicIssue int
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -118,7 +137,7 @@ func (s *EpicIssuesService) UpdateEpicIssueAssignment(gid interface{}, epic, epi
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -89,7 +106,7 @@ func (s *EpicsService) ListGroupEpics(gid interface{}, opt *ListGroupEpicsOption
}
u := fmt.Sprintf("groups/%s/epics", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -113,7 +130,7 @@ func (s *EpicsService) GetEpic(gid interface{}, epic int, options ...RequestOpti
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -137,7 +154,7 @@ func (s *EpicsService) GetEpicLinks(gid interface{}, epic int, options ...Reques
}
u := fmt.Sprintf("groups/%s/epics/%d/epics", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -174,7 +191,7 @@ func (s *EpicsService) CreateEpic(gid interface{}, opt *CreateEpicOptions, optio
}
u := fmt.Sprintf("groups/%s/epics", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -213,7 +230,7 @@ func (s *EpicsService) UpdateEpic(gid interface{}, epic int, opt *UpdateEpicOpti
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -237,7 +254,7 @@ func (s *EpicsService) DeleteEpic(gid interface{}, epic int, options ...RequestO
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,3 +1,19 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (

View file

@ -1,3 +1,19 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
// systemHookEvent is used to pre-process events to determine the

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -191,6 +191,10 @@ type IssueEvent struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
TotalTimeSpent struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"total_time_spent"`
} `json:"changes"`
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -90,7 +91,7 @@ func (s *UsersService) ListUserContributionEvents(uid interface{}, opt *ListCont
}
u := fmt.Sprintf("users/%s/events", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -108,7 +109,7 @@ func (s *UsersService) ListUserContributionEvents(uid interface{}, opt *ListCont
//
// GitLab API docs: https://docs.gitlab.com/ce/api/events.html#list-currently-authenticated-user-39-s-events
func (s *EventsService) ListCurrentUserContributionEvents(opt *ListContributionEventsOptions, options ...RequestOptionFunc) ([]*ContributionEvent, *Response, error) {
req, err := s.client.NewRequest("GET", "events", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "events", opt, options)
if err != nil {
return nil, nil, err
}
@ -132,7 +133,7 @@ func (s *EventsService) ListProjectVisibleEvents(pid interface{}, opt *ListContr
}
u := fmt.Sprintf("projects/%s/events", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -39,7 +56,7 @@ func (f Feature) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/features.html#list-all-features
func (s *FeaturesService) ListFeatures(options ...RequestOptionFunc) ([]*Feature, *Response, error) {
req, err := s.client.NewRequest("GET", "features", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "features", nil, options)
if err != nil {
return nil, nil, err
}
@ -65,7 +82,7 @@ func (s *FeaturesService) SetFeatureFlag(name string, value interface{}, options
value,
}
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2020 Paul Cioanca
// Copyright 2021 Paul Cioanca
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -60,7 +61,7 @@ func (s *FreezePeriodsService) ListFreezePeriods(pid interface{}, opt *ListFreez
}
u := fmt.Sprintf("projects/%s/freeze_periods", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -85,7 +86,7 @@ func (s *FreezePeriodsService) GetFreezePeriod(pid interface{}, freezePeriod int
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -121,7 +122,7 @@ func (s *FreezePeriodsService) CreateFreezePeriodOptions(pid interface{}, opt *C
}
u := fmt.Sprintf("projects/%s/freeze_periods", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -157,7 +158,7 @@ func (s *FreezePeriodsService) UpdateFreezePeriodOptions(pid interface{}, freeze
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -184,7 +185,7 @@ func (s *FreezePeriodsService) DeleteFreezePeriod(pid interface{}, freezePeriod
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -48,7 +49,7 @@ type ListTemplatesOptions ListOptions
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/gitignores.html#list-gitignore-templates
func (s *GitIgnoreTemplatesService) ListTemplates(opt *ListTemplatesOptions, options ...RequestOptionFunc) ([]*GitIgnoreTemplate, *Response, error) {
req, err := s.client.NewRequest("GET", "templates/gitignores", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "templates/gitignores", opt, options)
if err != nil {
return nil, nil, err
}
@ -69,7 +70,7 @@ func (s *GitIgnoreTemplatesService) ListTemplates(opt *ListTemplatesOptions, opt
func (s *GitIgnoreTemplatesService) GetTemplate(key string, options ...RequestOptionFunc) (*GitIgnoreTemplate, *Response, error) {
u := fmt.Sprintf("templates/gitignores/%s", url.PathEscape(key))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -100,6 +100,7 @@ type Client struct {
// Services used for talking to different parts of the GitLab API.
AccessRequests *AccessRequestsService
Applications *ApplicationsService
AuditEvents *AuditEventsService
AwardEmoji *AwardEmojiService
Boards *IssueBoardsService
Branches *BranchesService
@ -126,9 +127,11 @@ type Client struct {
GroupMembers *GroupMembersService
GroupMilestones *GroupMilestonesService
GroupVariables *GroupVariablesService
GroupWikis *GroupWikisService
Groups *GroupsService
InstanceCluster *InstanceClustersService
InstanceVariables *InstanceVariablesService
Invites *InvitesService
IssueLinks *IssueLinksService
Issues *IssuesService
IssuesStatistics *IssuesStatisticsService
@ -143,6 +146,7 @@ type Client struct {
Namespaces *NamespacesService
Notes *NotesService
NotificationSettings *NotificationSettingsService
Packages *PackagesService
PagesDomains *PagesDomainsService
PipelineSchedules *PipelineSchedulesService
PipelineTriggers *PipelineTriggersService
@ -156,12 +160,14 @@ type Client struct {
ProjectVariables *ProjectVariablesService
Projects *ProjectsService
ProtectedBranches *ProtectedBranchesService
ProtectedEnvironments *ProtectedEnvironmentsService
ProtectedTags *ProtectedTagsService
ReleaseLinks *ReleaseLinksService
Releases *ReleasesService
Repositories *RepositoriesService
RepositoryFiles *RepositoryFilesService
ResourceLabelEvents *ResourceLabelEventsService
ResourceStateEvents *ResourceStateEventsService
Runners *RunnersService
Search *SearchService
Services *ServicesService
@ -264,6 +270,7 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
// Create all the public services.
c.AccessRequests = &AccessRequestsService{client: c}
c.Applications = &ApplicationsService{client: c}
c.AuditEvents = &AuditEventsService{client: c}
c.AwardEmoji = &AwardEmojiService{client: c}
c.Boards = &IssueBoardsService{client: c}
c.Branches = &BranchesService{client: c}
@ -290,9 +297,11 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
c.GroupMembers = &GroupMembersService{client: c}
c.GroupMilestones = &GroupMilestonesService{client: c}
c.GroupVariables = &GroupVariablesService{client: c}
c.GroupWikis = &GroupWikisService{client: c}
c.Groups = &GroupsService{client: c}
c.InstanceCluster = &InstanceClustersService{client: c}
c.InstanceVariables = &InstanceVariablesService{client: c}
c.Invites = &InvitesService{client: c}
c.IssueLinks = &IssueLinksService{client: c}
c.Issues = &IssuesService{client: c, timeStats: timeStats}
c.IssuesStatistics = &IssuesStatisticsService{client: c}
@ -307,6 +316,7 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
c.Namespaces = &NamespacesService{client: c}
c.Notes = &NotesService{client: c}
c.NotificationSettings = &NotificationSettingsService{client: c}
c.Packages = &PackagesService{client: c}
c.PagesDomains = &PagesDomainsService{client: c}
c.PipelineSchedules = &PipelineSchedulesService{client: c}
c.PipelineTriggers = &PipelineTriggersService{client: c}
@ -320,12 +330,14 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
c.ProjectVariables = &ProjectVariablesService{client: c}
c.Projects = &ProjectsService{client: c}
c.ProtectedBranches = &ProtectedBranchesService{client: c}
c.ProtectedEnvironments = &ProtectedEnvironmentsService{client: c}
c.ProtectedTags = &ProtectedTagsService{client: c}
c.ReleaseLinks = &ReleaseLinksService{client: c}
c.Releases = &ReleasesService{client: c}
c.Repositories = &RepositoriesService{client: c}
c.RepositoryFiles = &RepositoryFilesService{client: c}
c.ResourceLabelEvents = &ResourceLabelEventsService{client: c}
c.ResourceStateEvents = &ResourceStateEventsService{client: c}
c.Runners = &RunnersService{client: c}
c.Search = &SearchService{client: c}
c.Services = &ServicesService{client: c}
@ -402,7 +414,7 @@ func rateLimitBackoff(min, max time.Duration, attemptNum int, resp *http.Respons
}
// configureLimiter configures the rate limiter.
func (c *Client) configureLimiter() error {
func (c *Client) configureLimiter(ctx context.Context) error {
// Set default values for when rate limiting is disabled.
limit := rate.Inf
burst := 0
@ -413,7 +425,7 @@ func (c *Client) configureLimiter() error {
}()
// Create a new request.
req, err := http.NewRequest("GET", c.baseURL.String(), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL.String(), nil)
if err != nil {
return err
}
@ -497,7 +509,7 @@ func (c *Client) NewRequest(method, path string, opt interface{}, options []Requ
var body interface{}
switch {
case method == "POST" || method == "PUT":
case method == http.MethodPost || method == http.MethodPut:
reqHeaders.Set("Content-Type", "application/json")
if opt != nil {
@ -601,7 +613,7 @@ func (r *Response) populatePageValues() {
func (c *Client) Do(req *retryablehttp.Request, v interface{}) (*Response, error) {
// If not yet configured, try to configure the rate limiter. Fail
// silently as the limiter will be disabled in case of an error.
c.configureLimiterOnce.Do(func() { c.configureLimiter() })
c.configureLimiterOnce.Do(func() { c.configureLimiter(req.Context()) })
// Wait will block until the limiter can obtain a new token.
err := c.limiter.Wait(req.Context())

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// GroupBadgesService handles communication with the group badges
@ -51,7 +68,7 @@ func (s *GroupBadgesService) ListGroupBadges(gid interface{}, opt *ListGroupBadg
}
u := fmt.Sprintf("groups/%s/badges", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -76,7 +93,7 @@ func (s *GroupBadgesService) GetGroupBadge(gid interface{}, badge int, options .
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -110,7 +127,7 @@ func (s *GroupBadgesService) AddGroupBadge(gid interface{}, opt *AddGroupBadgeOp
}
u := fmt.Sprintf("groups/%s/badges", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -144,7 +161,7 @@ func (s *GroupBadgesService) EditGroupBadge(gid interface{}, badge int, opt *Edi
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -169,7 +186,7 @@ func (s *GroupBadgesService) DeleteGroupBadge(gid interface{}, badge int, option
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -198,7 +215,7 @@ func (s *GroupBadgesService) PreviewGroupBadge(gid interface{}, opt *GroupBadgeP
}
u := fmt.Sprintf("groups/%s/badges/render", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// GroupIssueBoardsService handles communication with the group issue board
@ -63,7 +64,7 @@ func (s *GroupIssueBoardsService) ListGroupIssueBoards(gid interface{}, opt *Lis
}
u := fmt.Sprintf("groups/%s/boards", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -97,7 +98,7 @@ func (s *GroupIssueBoardsService) CreateGroupIssueBoard(gid interface{}, opt *Cr
}
u := fmt.Sprintf("groups/%s/boards", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -122,7 +123,7 @@ func (s *GroupIssueBoardsService) GetGroupIssueBoard(gid interface{}, board int,
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -159,7 +160,7 @@ func (s *GroupIssueBoardsService) UpdateIssueBoard(gid interface{}, board int, o
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -184,7 +185,7 @@ func (s *GroupIssueBoardsService) DeleteIssueBoard(gid interface{}, board int, o
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -210,7 +211,7 @@ func (s *GroupIssueBoardsService) ListGroupIssueBoardLists(gid interface{}, boar
}
u := fmt.Sprintf("groups/%s/boards/%d/lists", pathEscape(group), board)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -239,7 +240,7 @@ func (s *GroupIssueBoardsService) GetGroupIssueBoardList(gid interface{}, board,
list,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -273,7 +274,7 @@ func (s *GroupIssueBoardsService) CreateGroupIssueBoardList(gid interface{}, boa
}
u := fmt.Sprintf("groups/%s/boards/%d/lists", pathEscape(group), board)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -312,7 +313,7 @@ func (s *GroupIssueBoardsService) UpdateIssueBoardList(gid interface{}, board, l
list,
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -342,7 +343,7 @@ func (s *GroupIssueBoardsService) DeleteGroupIssueBoardList(gid interface{}, boa
list,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2019, Paul Shoemaker
// Copyright 2021, Paul Shoemaker
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -63,7 +64,7 @@ func (s *GroupClustersService) ListClusters(pid interface{}, options ...RequestO
}
u := fmt.Sprintf("groups/%s/clusters", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -88,7 +89,7 @@ func (s *GroupClustersService) GetCluster(pid interface{}, cluster int, options
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -136,7 +137,7 @@ func (s *GroupClustersService) AddCluster(pid interface{}, opt *AddGroupClusterO
}
u := fmt.Sprintf("groups/%s/clusters/user", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -180,7 +181,7 @@ func (s *GroupClustersService) EditCluster(pid interface{}, cluster int, opt *Ed
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -205,7 +206,7 @@ func (s *GroupClustersService) DeleteCluster(pid interface{}, cluster int, optio
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2020, Eric Stevens
// Copyright 2021, Eric Stevens
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -53,7 +54,7 @@ func (s *GroupsService) ListGroupHooks(gid interface{}) ([]*GroupHook, *Response
}
u := fmt.Sprintf("groups/%s/hooks", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, nil)
req, err := s.client.NewRequest(http.MethodGet, u, nil, nil)
if err != nil {
return nil, nil, err
}
@ -77,7 +78,7 @@ func (s *GroupsService) GetGroupHook(pid interface{}, hook int, options ...Reque
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -121,7 +122,7 @@ func (s *GroupsService) AddGroupHook(gid interface{}, opt *AddGroupHookOptions,
}
u := fmt.Sprintf("groups/%s/hooks", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -167,7 +168,7 @@ func (s *GroupsService) EditGroupHook(pid interface{}, hook int, opt *EditGroupH
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -193,7 +194,7 @@ func (s *GroupsService) DeleteGroupHook(pid interface{}, hook int, options ...Re
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// GroupLabelsService handles communication with the label related methods of the
@ -37,7 +54,7 @@ func (s *GroupLabelsService) ListGroupLabels(gid interface{}, opt *ListGroupLabe
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -66,7 +83,7 @@ func (s *GroupLabelsService) GetGroupLabel(gid interface{}, labelID interface{},
}
u := fmt.Sprintf("groups/%s/labels/%s", pathEscape(group), label)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -98,7 +115,7 @@ func (s *GroupLabelsService) CreateGroupLabel(gid interface{}, opt *CreateGroupL
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -128,7 +145,7 @@ func (s *GroupLabelsService) DeleteGroupLabel(gid interface{}, opt *DeleteGroupL
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
req, err := s.client.NewRequest("DELETE", u, opt, options)
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
@ -154,7 +171,7 @@ func (s *GroupLabelsService) UpdateGroupLabel(gid interface{}, opt *UpdateGroupL
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -185,7 +202,7 @@ func (s *GroupLabelsService) SubscribeToGroupLabel(gid interface{}, labelID inte
}
u := fmt.Sprintf("groups/%s/labels/%s/subscribe", pathEscape(group), label)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -216,7 +233,7 @@ func (s *GroupLabelsService) UnsubscribeFromGroupLabel(gid interface{}, labelID
}
u := fmt.Sprintf("groups/%s/labels/%s/unsubscribe", pathEscape(group), label)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// GroupMembersService handles communication with the group members
@ -76,7 +77,7 @@ func (s *GroupsService) ListGroupMembers(gid interface{}, opt *ListGroupMembersO
}
u := fmt.Sprintf("groups/%s/members", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -102,7 +103,7 @@ func (s *GroupsService) ListAllGroupMembers(gid interface{}, opt *ListGroupMembe
}
u := fmt.Sprintf("groups/%s/members/all", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -137,7 +138,7 @@ func (s *GroupMembersService) GetGroupMember(gid interface{}, user int, options
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -151,6 +152,56 @@ func (s *GroupMembersService) GetGroupMember(gid interface{}, user int, options
return gm, resp, err
}
// BillableGroupMember represents a GitLab billable group member.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
type BillableGroupMember struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
State string `json:"state"`
AvatarURL string `json:"avatar_url"`
WebURL string `json:"web_url"`
Email string `json:"email"`
LastActivityOn ISOTime `json:"last_activity_on"`
}
// ListBillableGroupMembersOptions represents the available ListBillableGroupMembers() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
type ListBillableGroupMembersOptions struct {
ListOptions
Search *string `url:"search,omitempty" json:"search,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
}
// ListBillableGroupMembers Gets a list of group members that count as billable.
// The list includes members in the subgroup or subproject.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
func (s *GroupsService) ListBillableGroupMembers(gid interface{}, opt *ListBillableGroupMembersOptions, options ...RequestOptionFunc) ([]*BillableGroupMember, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/billable_members", pathEscape(group))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var bgm []*BillableGroupMember
resp, err := s.client.Do(req, &bgm)
if err != nil {
return nil, resp, err
}
return bgm, resp, err
}
// AddGroupMember adds a user to the list of group members.
//
// GitLab API docs:
@ -162,7 +213,7 @@ func (s *GroupMembersService) AddGroupMember(gid interface{}, opt *AddGroupMembe
}
u := fmt.Sprintf("groups/%s/members", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -187,7 +238,7 @@ func (s *GroupMembersService) ShareWithGroup(gid interface{}, opt *ShareWithGrou
}
u := fmt.Sprintf("groups/%s/share", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -212,7 +263,7 @@ func (s *GroupMembersService) DeleteShareWithGroup(gid interface{}, groupID int,
}
u := fmt.Sprintf("groups/%s/share/%d", pathEscape(group), groupID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -241,7 +292,7 @@ func (s *GroupMembersService) EditGroupMember(gid interface{}, user int, opt *Ed
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -266,7 +317,7 @@ func (s *GroupMembersService) RemoveGroupMember(gid interface{}, user int, optio
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -75,7 +76,7 @@ func (s *GroupMilestonesService) ListGroupMilestones(gid interface{}, opt *ListG
}
u := fmt.Sprintf("groups/%s/milestones", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -100,7 +101,7 @@ func (s *GroupMilestonesService) GetGroupMilestone(gid interface{}, milestone in
}
u := fmt.Sprintf("groups/%s/milestones/%d", pathEscape(group), milestone)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -136,7 +137,7 @@ func (s *GroupMilestonesService) CreateGroupMilestone(gid interface{}, opt *Crea
}
u := fmt.Sprintf("groups/%s/milestones", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -173,7 +174,7 @@ func (s *GroupMilestonesService) UpdateGroupMilestone(gid interface{}, milestone
}
u := fmt.Sprintf("groups/%s/milestones/%d", pathEscape(group), milestone)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -204,7 +205,7 @@ func (s *GroupMilestonesService) GetGroupMilestoneIssues(gid interface{}, milest
}
u := fmt.Sprintf("groups/%s/milestones/%d/issues", pathEscape(group), milestone)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -237,7 +238,7 @@ func (s *GroupMilestonesService) GetGroupMilestoneMergeRequests(gid interface{},
}
u := fmt.Sprintf("groups/%s/milestones/%d/merge_requests", pathEscape(group), milestone)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -280,7 +281,7 @@ func (s *GroupMilestonesService) GetGroupMilestoneBurndownChartEvents(gid interf
}
u := fmt.Sprintf("groups/%s/milestones/%d/burndown_events", pathEscape(group), milestone)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -64,7 +65,7 @@ func (s *GroupVariablesService) ListVariables(gid interface{}, opt *ListGroupVar
}
u := fmt.Sprintf("groups/%s/variables", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -89,7 +90,7 @@ func (s *GroupVariablesService) GetVariable(gid interface{}, key string, options
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -127,7 +128,7 @@ func (s *GroupVariablesService) CreateVariable(gid interface{}, opt *CreateGroup
}
u := fmt.Sprintf("groups/%s/variables", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -165,7 +166,7 @@ func (s *GroupVariablesService) UpdateVariable(gid interface{}, key string, opt
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -190,7 +191,7 @@ func (s *GroupVariablesService) RemoveVariable(gid interface{}, key string, opti
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

194
vendor/github.com/xanzy/go-gitlab/group_wikis.go generated vendored Normal file
View file

@ -0,0 +1,194 @@
//
// Copyright 2021, Markus Lackner
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gitlab
import (
"fmt"
"net/http"
"net/url"
)
// GroupWikisService handles communication with the group wikis related methods of
// the Gitlab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/group_wikis.html
type GroupWikisService struct {
client *Client
}
// GroupWiki represents a GitLab groups wiki.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/group_wikis.html
type GroupWiki struct {
Content string `json:"content"`
Format WikiFormatValue `json:"format"`
Slug string `json:"slug"`
Title string `json:"title"`
}
func (w GroupWiki) String() string {
return Stringify(w)
}
// ListGroupWikisOptions represents the available ListGroupWikis options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#list-wiki-pages
type ListGroupWikisOptions struct {
WithContent *bool `url:"with_content,omitempty" json:"with_content,omitempty"`
}
// ListGroupWikis lists all pages of the wiki of the given group id.
// When with_content is set, it also returns the content of the pages.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#list-wiki-pages
func (s *GroupWikisService) ListGroupWikis(gid interface{}, opt *ListGroupWikisOptions, options ...RequestOptionFunc) ([]*GroupWiki, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/wikis", pathEscape(group))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var gws []*GroupWiki
resp, err := s.client.Do(req, &gws)
if err != nil {
return nil, resp, err
}
return gws, resp, err
}
// GetGroupWikiPage gets a wiki page for a given group.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#get-a-wiki-page
func (s *GroupWikisService) GetGroupWikiPage(gid interface{}, slug string, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
gw := new(GroupWiki)
resp, err := s.client.Do(req, gw)
if err != nil {
return nil, resp, err
}
return gw, resp, err
}
// CreateGroupWikiPageOptions represents options to CreateGroupWikiPage.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#create-a-new-wiki-page
type CreateGroupWikiPageOptions struct {
Content *string `url:"content,omitempty" json:"content,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// CreateGroupWikiPage creates a new wiki page for the given group with
// the given title, slug, and content.
//
// GitLab API docs:
// https://docs.gitlab.com/13.8/ee/api/group_wikis.html#create-a-new-wiki-page
func (s *GroupWikisService) CreateGroupWikiPage(gid interface{}, opt *CreateGroupWikiPageOptions, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/wikis", pathEscape(group))
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
w := new(GroupWiki)
resp, err := s.client.Do(req, w)
if err != nil {
return nil, resp, err
}
return w, resp, err
}
// EditGroupWikiPageOptions represents options to EditGroupWikiPage.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#edit-an-existing-wiki-page
type EditGroupWikiPageOptions struct {
Content *string `url:"content,omitempty" json:"content,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// EditGroupWikiPage Updates an existing wiki page. At least one parameter is
// required to update the wiki page.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#edit-an-existing-wiki-page
func (s *GroupWikisService) EditGroupWikiPage(gid interface{}, slug string, opt *EditGroupWikiPageOptions, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
w := new(GroupWiki)
resp, err := s.client.Do(req, w)
if err != nil {
return nil, resp, err
}
return w, resp, err
}
// DeleteGroupWikiPage deletes a wiki page with a given slug.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_wikis.html#delete-a-wiki-page
func (s *GroupWikisService) DeleteGroupWikiPage(gid interface{}, slug string, options ...RequestOptionFunc) (*Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -106,7 +107,7 @@ type ListGroupsOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/groups.html#list-project-groups
func (s *GroupsService) ListGroups(opt *ListGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) {
req, err := s.client.NewRequest("GET", "groups", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "groups", opt, options)
if err != nil {
return nil, nil, err
}
@ -130,7 +131,7 @@ func (s *GroupsService) GetGroup(gid interface{}, options ...RequestOptionFunc)
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -173,7 +174,7 @@ type CreateGroupOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#new-group
func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...RequestOptionFunc) (*Group, *Response, error) {
req, err := s.client.NewRequest("POST", "groups", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "groups", opt, options)
if err != nil {
return nil, nil, err
}
@ -203,7 +204,7 @@ func (s *GroupsService) TransferGroup(gid interface{}, pid interface{}, options
}
u := fmt.Sprintf("groups/%s/projects/%s", pathEscape(group), pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -234,7 +235,7 @@ func (s *GroupsService) UpdateGroup(gid interface{}, opt *UpdateGroupOptions, op
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -258,7 +259,7 @@ func (s *GroupsService) DeleteGroup(gid interface{}, options ...RequestOptionFun
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -277,7 +278,7 @@ func (s *GroupsService) RestoreGroup(gid interface{}, options ...RequestOptionFu
}
u := fmt.Sprintf("groups/%s/restore", pathEscape(group))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -300,7 +301,7 @@ func (s *GroupsService) SearchGroup(query string, options ...RequestOptionFunc)
}
q.Search = query
req, err := s.client.NewRequest("GET", "groups", &q, options)
req, err := s.client.NewRequest(http.MethodGet, "groups", &q, options)
if err != nil {
return nil, nil, err
}
@ -320,19 +321,21 @@ func (s *GroupsService) SearchGroup(query string, options ...RequestOptionFunc)
// https://docs.gitlab.com/ce/api/groups.html#list-a-group-39-s-projects
type ListGroupProjectsOptions struct {
ListOptions
Archived *bool `url:"archived,omitempty" json:"archived,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
Search *string `url:"search,omitempty" json:"search,omitempty"`
Simple *bool `url:"simple,omitempty" json:"simple,omitempty"`
Owned *bool `url:"owned,omitempty" json:"owned,omitempty"`
Starred *bool `url:"starred,omitempty" json:"starred,omitempty"`
WithIssuesEnabled *bool `url:"with_issues_enabled,omitempty" json:"with_issues_enabled,omitempty"`
WithMergeRequestsEnabled *bool `url:"with_merge_requests_enabled,omitempty" json:"with_merge_requests_enabled,omitempty"`
WithShared *bool `url:"with_shared,omitempty" json:"with_shared,omitempty"`
IncludeSubgroups *bool `url:"include_subgroups,omitempty" json:"include_subgroups,omitempty"`
WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
Archived *bool `url:"archived,omitempty" json:"archived,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
Search *string `url:"search,omitempty" json:"search,omitempty"`
Simple *bool `url:"simple,omitempty" json:"simple,omitempty"`
Owned *bool `url:"owned,omitempty" json:"owned,omitempty"`
Starred *bool `url:"starred,omitempty" json:"starred,omitempty"`
WithIssuesEnabled *bool `url:"with_issues_enabled,omitempty" json:"with_issues_enabled,omitempty"`
WithMergeRequestsEnabled *bool `url:"with_merge_requests_enabled,omitempty" json:"with_merge_requests_enabled,omitempty"`
WithShared *bool `url:"with_shared,omitempty" json:"with_shared,omitempty"`
IncludeSubgroups *bool `url:"include_subgroups,omitempty" json:"include_subgroups,omitempty"`
MinAccessLevel *AccessLevelValue `url:"min_access_level,omitempty" json:"min_access_level,omitempty"`
WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
WithSecurityReports *bool `url:"with_security_reports,omitempty" json:"with_security_reports,omitempty"`
}
// ListGroupProjects get a list of group projects
@ -346,7 +349,7 @@ func (s *GroupsService) ListGroupProjects(gid interface{}, opt *ListGroupProject
}
u := fmt.Sprintf("groups/%s/projects", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -377,7 +380,7 @@ func (s *GroupsService) ListSubgroups(gid interface{}, opt *ListSubgroupsOptions
}
u := fmt.Sprintf("groups/%s/subgroups", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -409,7 +412,7 @@ func (s *GroupsService) ListDescendantGroups(gid interface{}, opt *ListDescendan
}
u := fmt.Sprintf("groups/%s/descendant_groups", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -435,7 +438,7 @@ func (s *GroupsService) ListGroupLDAPLinks(gid interface{}, options ...RequestOp
}
u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -471,7 +474,7 @@ func (s *GroupsService) AddGroupLDAPLink(gid interface{}, opt *AddGroupLDAPLinkO
}
u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -497,7 +500,7 @@ func (s *GroupsService) DeleteGroupLDAPLink(gid interface{}, cn string, options
}
u := fmt.Sprintf("groups/%s/ldap_group_links/%s", pathEscape(group), pathEscape(cn))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -522,7 +525,61 @@ func (s *GroupsService) DeleteGroupLDAPLinkForProvider(gid interface{}, provider
pathEscape(cn),
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
// ShareGroupWithGroupOptions represents the available ShareGroupWithGroup() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#share-groups-with-groups
type ShareGroupWithGroupOptions struct {
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
GroupAccess *AccessLevelValue `url:"group_access,omitempty" json:"group_access,omitempty"`
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
}
// ShareGroupWithGroup shares a group with another group.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#create-a-link-to-share-a-group-with-another-group
func (s *GroupsService) ShareGroupWithGroup(gid interface{}, opt *ShareGroupWithGroupOptions, options ...RequestOptionFunc) (*Group, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/share", pathEscape(group))
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
g := new(Group)
resp, err := s.client.Do(req, g)
if err != nil {
return nil, resp, err
}
return g, resp, err
}
// UnshareGroupFromGroup unshares a group from another group.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#delete-link-sharing-group-with-another-group
func (s *GroupsService) UnshareGroupFromGroup(gid interface{}, groupID int, options ...RequestOptionFunc) (*Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("groups/%s/share/%d", pathEscape(group), groupID)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -561,7 +618,7 @@ func (s *GroupsService) GetGroupPushRules(gid interface{}, options ...RequestOpt
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -605,7 +662,7 @@ func (s *GroupsService) AddGroupPushRule(gid interface{}, opt *AddGroupPushRuleO
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -649,7 +706,7 @@ func (s *GroupsService) EditGroupPushRule(gid interface{}, opt *EditGroupPushRul
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -674,7 +731,7 @@ func (s *GroupsService) DeleteGroupPushRule(gid interface{}, options ...RequestO
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2020, Serena Fang
// Copyright 2021, Serena Fang
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -59,7 +60,7 @@ func (v InstanceCluster) String() string {
func (s *InstanceClustersService) ListClusters(options ...RequestOptionFunc) ([]*InstanceCluster, *Response, error) {
u := "admin/clusters"
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -80,7 +81,7 @@ func (s *InstanceClustersService) ListClusters(options ...RequestOptionFunc) ([]
func (s *InstanceClustersService) GetCluster(cluster int, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -101,7 +102,7 @@ func (s *InstanceClustersService) GetCluster(cluster int, options ...RequestOpti
func (s *InstanceClustersService) AddCluster(opt *AddClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := "admin/clusters/add"
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -122,7 +123,7 @@ func (s *InstanceClustersService) AddCluster(opt *AddClusterOptions, options ...
func (s *InstanceClustersService) EditCluster(cluster int, opt *EditClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -143,7 +144,7 @@ func (s *InstanceClustersService) EditCluster(cluster int, opt *EditClusterOptio
func (s *InstanceClustersService) DeleteCluster(cluster int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -60,7 +61,7 @@ type ListInstanceVariablesOptions ListOptions
func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptions, options ...RequestOptionFunc) ([]*InstanceVariable, *Response, error) {
u := "admin/ci/variables"
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -81,7 +82,7 @@ func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptio
func (s *InstanceVariablesService) GetVariable(key string, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -115,7 +116,7 @@ type CreateInstanceVariableOptions struct {
func (s *InstanceVariablesService) CreateVariable(opt *CreateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := "admin/ci/variables"
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -149,7 +150,7 @@ type UpdateInstanceVariableOptions struct {
func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -170,7 +171,7 @@ func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanc
func (s *InstanceVariablesService) RemoveVariable(key string, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

175
vendor/github.com/xanzy/go-gitlab/invites.go generated vendored Normal file
View file

@ -0,0 +1,175 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
// InvitesService handles communication with the invitation related
// methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/invitations.html
type InvitesService struct {
client *Client
}
// PendingInvite represents a pending invite.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/invitations.html
type PendingInvite struct {
ID int `json:"id"`
InviteEmail string `json:"invite_email"`
CreatedAt *time.Time `json:"created_at"`
AccessLevel AccessLevelValue `json:"access_level"`
ExpiresAt *time.Time `json:"expires_at"`
UserName string `json:"user_name"`
CreatedByName string `json:"created_by_name"`
}
// ListPendingInvitationsOptions represents the available
// ListPendingInvitations() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
type ListPendingInvitationsOptions struct {
ListOptions
Query *string `url:"query,omitempty" json:"query,omitempty"`
}
// ListPendingGroupInvitations gets a list of invited group members.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
func (s *InvitesService) ListPendingGroupInvitations(gid interface{}, opt *ListPendingInvitationsOptions, options ...RequestOptionFunc) ([]*PendingInvite, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/invitations", pathEscape(group))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var pis []*PendingInvite
resp, err := s.client.Do(req, &pis)
if err != nil {
return nil, resp, err
}
return pis, resp, err
}
// ListPendingProjectInvitations gets a list of invited project members.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
func (s *InvitesService) ListPendingProjectInvitations(pid interface{}, opt *ListPendingInvitationsOptions, options ...RequestOptionFunc) ([]*PendingInvite, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/invitations", pathEscape(project))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var pis []*PendingInvite
resp, err := s.client.Do(req, &pis)
if err != nil {
return nil, resp, err
}
return pis, resp, err
}
// InvitesOptions represents the available GroupInvites() and ProjectInvites()
// options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
type InvitesOptions struct {
ID interface{} `url:"id,omitempty" json:"id,omitempty"`
Email *string `url:"email,omitempty" json:"email,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
}
// InvitesResult represents an invitations result.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
type InvitesResult struct {
Status string `json:"status"`
Message map[string]string `json:"message,omitempty"`
}
// GroupInvites invites new users by email to join a group.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
func (s *InvitesService) GroupInvites(gid interface{}, opt *InvitesOptions, options ...RequestOptionFunc) (*InvitesResult, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/invitations", pathEscape(group))
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
ir := new(InvitesResult)
resp, err := s.client.Do(req, ir)
if err != nil {
return nil, resp, err
}
return ir, resp, err
}
// ProjectInvites invites new users by email to join a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
func (s *InvitesService) ProjectInvites(pid interface{}, opt *InvitesOptions, options ...RequestOptionFunc) (*InvitesResult, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/invitations", pathEscape(project))
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
ir := new(InvitesResult)
resp, err := s.client.Do(req, ir)
if err != nil {
return nil, resp, err
}
return ir, resp, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Arkbriar
// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// IssueLinksService handles communication with the issue relations related methods
@ -51,7 +52,7 @@ func (s *IssueLinksService) ListIssueRelations(pid interface{}, issueIID int, op
}
u := fmt.Sprintf("projects/%s/issues/%d/links", pathEscape(project), issueIID)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -86,7 +87,7 @@ func (s *IssueLinksService) CreateIssueLink(pid interface{}, issueIID int, opt *
}
u := fmt.Sprintf("projects/%s/issues/%d/links", pathEscape(project), issueIID)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -114,7 +115,7 @@ func (s *IssueLinksService) DeleteIssueLink(pid interface{}, issueIID, issueLink
issueIID,
issueLinkID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
"time"
@ -232,7 +233,7 @@ type ListIssuesOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-issues
func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) {
req, err := s.client.NewRequest("GET", "issues", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "issues", opt, options)
if err != nil {
return nil, nil, err
}
@ -288,7 +289,7 @@ func (s *IssuesService) ListGroupIssues(pid interface{}, opt *ListGroupIssuesOpt
}
u := fmt.Sprintf("groups/%s/issues", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -328,6 +329,7 @@ type ListProjectIssuesOptions struct {
In *string `url:"in,omitempty" json:"in,omitempty"`
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
DueDate *string `url:"due_date,omitempty" json:"due_date,omitempty"`
UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"`
UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"`
Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"`
@ -344,7 +346,7 @@ func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssue
}
u := fmt.Sprintf("projects/%s/issues", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -368,7 +370,7 @@ func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...RequestO
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -410,7 +412,7 @@ func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, op
}
u := fmt.Sprintf("projects/%s/issues", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -454,7 +456,7 @@ func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssue
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -478,7 +480,7 @@ func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...Reque
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -504,7 +506,7 @@ func (s *IssuesService) MoveIssue(pid interface{}, issue int, opt *MoveIssueOpti
}
u := fmt.Sprintf("projects/%s/issues/%d/move", pathEscape(project), issue)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -531,7 +533,7 @@ func (s *IssuesService) SubscribeToIssue(pid interface{}, issue int, options ...
}
u := fmt.Sprintf("projects/%s/issues/%d/subscribe", pathEscape(project), issue)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -558,7 +560,7 @@ func (s *IssuesService) UnsubscribeFromIssue(pid interface{}, issue int, options
}
u := fmt.Sprintf("projects/%s/issues/%d/unsubscribe", pathEscape(project), issue)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -591,7 +593,7 @@ func (s *IssuesService) ListMergeRequestsClosingIssue(pid interface{}, issue int
}
u := fmt.Sprintf("/projects/%s/issues/%d/closed_by", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -627,7 +629,7 @@ func (s *IssuesService) ListMergeRequestsRelatedToIssue(pid interface{}, issue i
issue,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -692,7 +694,7 @@ func (s *IssuesService) GetParticipants(pid interface{}, issue int, options ...R
}
u := fmt.Sprintf("projects/%s/issues/%d/participants", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -75,7 +76,7 @@ type GetIssuesStatisticsOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-issues-statistics
func (s *IssuesStatisticsService) GetIssuesStatistics(opt *GetIssuesStatisticsOptions, options ...RequestOptionFunc) (*IssuesStatistics, *Response, error) {
req, err := s.client.NewRequest("GET", "issues_statistics", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "issues_statistics", opt, options)
if err != nil {
return nil, nil, err
}
@ -97,7 +98,7 @@ func (s *IssuesStatisticsService) GetIssuesStatistics(opt *GetIssuesStatisticsOp
type GetGroupIssuesStatisticsOptions struct {
Labels Labels `url:"labels,omitempty" json:"labels,omitempty"`
IIDs []int `url:"iids,omitempty" json:"iids,omitempty"`
Milestone *Milestone `url:"milestone,omitempty" json:"milestone,omitempty"`
Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"`
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"`
@ -123,7 +124,7 @@ func (s *IssuesStatisticsService) GetGroupIssuesStatistics(gid interface{}, opt
}
u := fmt.Sprintf("groups/%s/issues_statistics", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -171,7 +172,7 @@ func (s *IssuesStatisticsService) GetProjectIssuesStatistics(pid interface{}, op
}
u := fmt.Sprintf("projects/%s/issues_statistics", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Arkbriar
// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"bytes"
"fmt"
"net/http"
"time"
)
@ -118,7 +119,7 @@ func (s *JobsService) ListProjectJobs(pid interface{}, opts *ListJobsOptions, op
}
u := fmt.Sprintf("projects/%s/jobs", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -144,7 +145,7 @@ func (s *JobsService) ListPipelineJobs(pid interface{}, pipelineID int, opts *Li
}
u := fmt.Sprintf("projects/%s/pipelines/%d/jobs", pathEscape(project), pipelineID)
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -170,7 +171,7 @@ func (s *JobsService) ListPipelineBridges(pid interface{}, pipelineID int, opts
}
u := fmt.Sprintf("projects/%s/pipelines/%d/bridges", pathEscape(project), pipelineID)
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -195,7 +196,7 @@ func (s *JobsService) GetJob(pid interface{}, jobID int, options ...RequestOptio
}
u := fmt.Sprintf("projects/%s/jobs/%d", pathEscape(project), jobID)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -220,7 +221,7 @@ func (s *JobsService) GetJobArtifacts(pid interface{}, jobID int, options ...Req
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts", pathEscape(project), jobID)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -255,7 +256,7 @@ func (s *JobsService) DownloadArtifactsFile(pid interface{}, refName string, opt
}
u := fmt.Sprintf("projects/%s/jobs/artifacts/%s/download", pathEscape(project), refName)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -289,7 +290,7 @@ func (s *JobsService) DownloadSingleArtifactsFile(pid interface{}, jobID int, ar
artifactPath,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -314,7 +315,7 @@ func (s *JobsService) GetTraceFile(pid interface{}, jobID int, options ...Reques
}
u := fmt.Sprintf("projects/%s/jobs/%d/trace", pathEscape(project), jobID)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -339,7 +340,7 @@ func (s *JobsService) CancelJob(pid interface{}, jobID int, options ...RequestOp
}
u := fmt.Sprintf("projects/%s/jobs/%d/cancel", pathEscape(project), jobID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -364,7 +365,7 @@ func (s *JobsService) RetryJob(pid interface{}, jobID int, options ...RequestOpt
}
u := fmt.Sprintf("projects/%s/jobs/%d/retry", pathEscape(project), jobID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -390,7 +391,7 @@ func (s *JobsService) EraseJob(pid interface{}, jobID int, options ...RequestOpt
}
u := fmt.Sprintf("projects/%s/jobs/%d/erase", pathEscape(project), jobID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -416,7 +417,7 @@ func (s *JobsService) KeepArtifacts(pid interface{}, jobID int, options ...Reque
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts/keep", pathEscape(project), jobID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -441,7 +442,7 @@ func (s *JobsService) PlayJob(pid interface{}, jobID int, options ...RequestOpti
}
u := fmt.Sprintf("projects/%s/jobs/%d/play", pathEscape(project), jobID)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -466,7 +467,7 @@ func (s *JobsService) DeleteArtifacts(pid interface{}, jobID int, options ...Req
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts", pathEscape(project), jobID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -50,7 +51,7 @@ type Key struct {
func (s *KeysService) GetKeyWithUser(key int, options ...RequestOptionFunc) (*Key, *Response, error) {
u := fmt.Sprintf("keys/%d", key)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"encoding/json"
"fmt"
"net/http"
)
// LabelsService handles communication with the label related methods of the
@ -89,7 +90,7 @@ func (s *LabelsService) ListLabels(pid interface{}, opt *ListLabelsOptions, opti
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -117,7 +118,7 @@ func (s *LabelsService) GetLabel(pid interface{}, labelID interface{}, options .
}
u := fmt.Sprintf("projects/%s/labels/%s", pathEscape(project), label)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -151,7 +152,7 @@ func (s *LabelsService) CreateLabel(pid interface{}, opt *CreateLabelOptions, op
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -182,7 +183,7 @@ func (s *LabelsService) DeleteLabel(pid interface{}, opt *DeleteLabelOptions, op
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, opt, options)
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
@ -211,7 +212,7 @@ func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, op
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -242,7 +243,7 @@ func (s *LabelsService) SubscribeToLabel(pid interface{}, labelID interface{}, o
}
u := fmt.Sprintf("projects/%s/labels/%s/subscribe", pathEscape(project), label)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -273,7 +274,7 @@ func (s *LabelsService) UnsubscribeFromLabel(pid interface{}, labelID interface{
}
u := fmt.Sprintf("projects/%s/labels/%s/unsubscribe", pathEscape(project), label)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
@ -296,7 +297,7 @@ func (s *LabelsService) PromoteLabel(pid interface{}, labelID interface{}, optio
}
u := fmt.Sprintf("projects/%s/labels/%s/promote", pathEscape(project), label)
req, err := s.client.NewRequest("PUT", u, nil, options)
req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,7 +16,10 @@
package gitlab
import "time"
import (
"net/http"
"time"
)
// LicenseService handles communication with the license
// related methods of the GitLab API.
@ -68,7 +71,7 @@ func (l License) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/license.html#retrieve-information-about-the-current-license
func (s *LicenseService) GetLicense() (*License, *Response, error) {
req, err := s.client.NewRequest("GET", "license", nil, nil)
req, err := s.client.NewRequest(http.MethodGet, "license", nil, nil)
if err != nil {
return nil, nil, err
}
@ -94,7 +97,7 @@ type AddLicenseOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/license.html#add-a-new-license
func (s *LicenseService) AddLicense(opt *AddLicenseOptions, options ...RequestOptionFunc) (*License, *Response, error) {
req, err := s.client.NewRequest("POST", "license", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "license", opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// LicenseTemplate represents a license template.
@ -45,7 +62,7 @@ type ListLicenseTemplatesOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/licenses.html#list-license-templates
func (s *LicenseTemplatesService) ListLicenseTemplates(opt *ListLicenseTemplatesOptions, options ...RequestOptionFunc) ([]*LicenseTemplate, *Response, error) {
req, err := s.client.NewRequest("GET", "templates/licenses", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "templates/licenses", opt, options)
if err != nil {
return nil, nil, err
}
@ -77,7 +94,7 @@ type GetLicenseTemplateOptions struct {
func (s *LicenseTemplatesService) GetLicenseTemplate(template string, opt *GetLicenseTemplateOptions, options ...RequestOptionFunc) (*LicenseTemplate, *Response, error) {
u := fmt.Sprintf("templates/licenses/%s", template)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -120,7 +137,7 @@ func (s *MergeRequestApprovalsService) ApproveMergeRequest(pid interface{}, mr i
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approve", pathEscape(project), mr)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -145,7 +162,7 @@ func (s *MergeRequestApprovalsService) UnapproveMergeRequest(pid interface{}, mr
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/unapprove", pathEscape(project), mr)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
@ -173,7 +190,7 @@ func (s *MergeRequestApprovalsService) GetConfiguration(pid interface{}, mr int,
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mr)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -198,7 +215,7 @@ func (s *MergeRequestApprovalsService) ChangeApprovalConfiguration(pid interface
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -233,7 +250,7 @@ func (s *MergeRequestApprovalsService) ChangeAllowedApprovers(pid interface{}, m
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvers", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -258,7 +275,7 @@ func (s *MergeRequestApprovalsService) GetApprovalRules(pid interface{}, mergeRe
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -283,7 +300,7 @@ func (s *MergeRequestApprovalsService) GetApprovalState(pid interface{}, mergeRe
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_state", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -321,7 +338,7 @@ func (s *MergeRequestApprovalsService) CreateApprovalRule(pid interface{}, merge
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -358,7 +375,7 @@ func (s *MergeRequestApprovalsService) UpdateApprovalRule(pid interface{}, merge
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", pathEscape(project), mergeRequest, approvalRule)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -383,7 +400,7 @@ func (s *MergeRequestApprovalsService) DeleteApprovalRule(pid interface{}, merge
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", pathEscape(project), mergeRequest, approvalRule)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -48,6 +49,7 @@ type MergeRequest struct {
Author *BasicUser `json:"author"`
Assignee *BasicUser `json:"assignee"`
Assignees []*BasicUser `json:"assignees"`
Reviewers []*BasicUser `json:"reviewers"`
SourceProjectID int `json:"source_project_id"`
TargetProjectID int `json:"target_project_id"`
Labels Labels `json:"labels"`
@ -69,6 +71,7 @@ type MergeRequest struct {
ChangesCount string `json:"changes_count"`
ShouldRemoveSourceBranch bool `json:"should_remove_source_branch"`
ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
AllowCollaboration bool `json:"allow_collaboration"`
WebURL string `json:"web_url"`
DiscussionLocked bool `json:"discussion_locked"`
Changes []struct {
@ -101,7 +104,9 @@ type MergeRequest struct {
Count int `json:"count"`
CompletedCount int `json:"completed_count"`
} `json:"task_completion_status"`
HasConflicts bool `json:"has_conflicts"`
HasConflicts bool `json:"has_conflicts"`
BlockingDiscussionsResolved bool `json:"blocking_discussions_resolved"`
Overflow bool `json:"overflow"`
}
func (m MergeRequest) String() string {
@ -152,6 +157,8 @@ type ListMergeRequestsOptions struct {
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
@ -168,7 +175,7 @@ type ListMergeRequestsOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#list-merge-requests
func (s *MergeRequestsService) ListMergeRequests(opt *ListMergeRequestsOptions, options ...RequestOptionFunc) ([]*MergeRequest, *Response, error) {
req, err := s.client.NewRequest("GET", "merge_requests", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "merge_requests", opt, options)
if err != nil {
return nil, nil, err
}
@ -205,6 +212,8 @@ type ListGroupMergeRequestsOptions struct {
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
@ -222,7 +231,7 @@ func (s *MergeRequestsService) ListGroupMergeRequests(gid interface{}, opt *List
}
u := fmt.Sprintf("groups/%s/merge_requests", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -260,6 +269,8 @@ type ListProjectMergeRequestsOptions struct {
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
@ -278,7 +289,7 @@ func (s *MergeRequestsService) ListProjectMergeRequests(pid interface{}, opt *Li
}
u := fmt.Sprintf("projects/%s/merge_requests", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -314,7 +325,7 @@ func (s *MergeRequestsService) GetMergeRequest(pid interface{}, mergeRequest int
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -339,7 +350,7 @@ func (s *MergeRequestsService) GetMergeRequestApprovals(pid interface{}, mergeRe
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -371,7 +382,7 @@ func (s *MergeRequestsService) GetMergeRequestCommits(pid interface{}, mergeRequ
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/commits", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -385,19 +396,28 @@ func (s *MergeRequestsService) GetMergeRequestCommits(pid interface{}, mergeRequ
return c, resp, err
}
// GetMergeRequestChangesOptions represents the available GetMergeRequestChanges()
// options.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-changes
type GetMergeRequestChangesOptions struct {
AccessRawDiffs *bool `url:"access_raw_diffs,omitempty" json:"access_raw_diffs,omitempty"`
}
// GetMergeRequestChanges shows information about the merge request including
// its files and changes.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-changes
func (s *MergeRequestsService) GetMergeRequestChanges(pid interface{}, mergeRequest int, options ...RequestOptionFunc) (*MergeRequest, *Response, error) {
func (s *MergeRequestsService) GetMergeRequestChanges(pid interface{}, mergeRequest int, opt *GetMergeRequestChangesOptions, options ...RequestOptionFunc) (*MergeRequest, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/changes", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -422,7 +442,7 @@ func (s *MergeRequestsService) GetMergeRequestParticipants(pid interface{}, merg
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/participants", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -447,7 +467,7 @@ func (s *MergeRequestsService) ListMergeRequestPipelines(pid interface{}, mergeR
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/pipelines", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -472,7 +492,7 @@ func (s *MergeRequestsService) CreateMergeRequestPipeline(pid interface{}, merge
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/pipelines", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -505,7 +525,7 @@ func (s *MergeRequestsService) GetIssuesClosedOnMerge(pid interface{}, mergeRequ
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/closes_issues", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -532,6 +552,7 @@ type CreateMergeRequestOptions struct {
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
AssigneeIDs []int `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"`
ReviewerIDs []int `url:"reviewer_ids,omitempty" json:"reviewer_ids,omitempty"`
TargetProjectID *int `url:"target_project_id,omitempty" json:"target_project_id,omitempty"`
MilestoneID *int `url:"milestone_id,omitempty" json:"milestone_id,omitempty"`
RemoveSourceBranch *bool `url:"remove_source_branch,omitempty" json:"remove_source_branch,omitempty"`
@ -550,7 +571,7 @@ func (s *MergeRequestsService) CreateMergeRequest(pid interface{}, opt *CreateMe
}
u := fmt.Sprintf("projects/%s/merge_requests", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -575,6 +596,7 @@ type UpdateMergeRequestOptions struct {
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
AssigneeIDs []int `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"`
ReviewerIDs []int `url:"reviewer_ids,omitempty" json:"reviewer_ids,omitempty"`
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
AddLabels Labels `url:"add_labels,comma,omitempty" json:"add_labels,omitempty"`
RemoveLabels Labels `url:"remove_labels,comma,omitempty" json:"remove_labels,omitempty"`
@ -597,7 +619,7 @@ func (s *MergeRequestsService) UpdateMergeRequest(pid interface{}, mergeRequest
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -622,7 +644,7 @@ func (s *MergeRequestsService) DeleteMergeRequest(pid interface{}, mergeRequest
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -658,7 +680,7 @@ func (s *MergeRequestsService) AcceptMergeRequest(pid interface{}, mergeRequest
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/merge", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -687,7 +709,7 @@ func (s *MergeRequestsService) CancelMergeWhenPipelineSucceeds(pid interface{},
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/cancel_merge_when_pipeline_succeeds", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, nil, options)
req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -714,7 +736,7 @@ func (s *MergeRequestsService) RebaseMergeRequest(pid interface{}, mergeRequest
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/rebase", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, nil, options)
req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, err
}
@ -740,7 +762,7 @@ func (s *MergeRequestsService) GetMergeRequestDiffVersions(pid interface{}, merg
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/versions", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -765,7 +787,7 @@ func (s *MergeRequestsService) GetSingleMergeRequestDiffVersion(pid interface{},
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/versions/%d", pathEscape(project), mergeRequest, version)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -792,7 +814,7 @@ func (s *MergeRequestsService) SubscribeToMergeRequest(pid interface{}, mergeReq
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/subscribe", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -820,7 +842,7 @@ func (s *MergeRequestsService) UnsubscribeFromMergeRequest(pid interface{}, merg
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/unsubscribe", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -847,7 +869,7 @@ func (s *MergeRequestsService) CreateTodo(pid interface{}, mergeRequest int, opt
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/todo", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -74,7 +75,7 @@ func (s *MilestonesService) ListMilestones(pid interface{}, opt *ListMilestonesO
}
u := fmt.Sprintf("projects/%s/milestones", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -99,7 +100,7 @@ func (s *MilestonesService) GetMilestone(pid interface{}, milestone int, options
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -135,7 +136,7 @@ func (s *MilestonesService) CreateMilestone(pid interface{}, opt *CreateMileston
}
u := fmt.Sprintf("projects/%s/milestones", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -172,7 +173,7 @@ func (s *MilestonesService) UpdateMilestone(pid interface{}, milestone int, opt
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -197,7 +198,7 @@ func (s *MilestonesService) DeleteMilestone(pid interface{}, milestone int, opti
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -221,7 +222,7 @@ func (s *MilestonesService) GetMilestoneIssues(pid interface{}, milestone int, o
}
u := fmt.Sprintf("projects/%s/milestones/%d/issues", pathEscape(project), milestone)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -254,7 +255,7 @@ func (s *MilestonesService) GetMilestoneMergeRequests(pid interface{}, milestone
}
u := fmt.Sprintf("projects/%s/milestones/%d/merge_requests", pathEscape(project), milestone)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// NamespacesService handles communication with the namespace related methods
@ -57,7 +58,7 @@ type ListNamespacesOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions, options ...RequestOptionFunc) ([]*Namespace, *Response, error) {
req, err := s.client.NewRequest("GET", "namespaces", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "namespaces", opt, options)
if err != nil {
return nil, nil, err
}
@ -82,7 +83,7 @@ func (s *NamespacesService) SearchNamespace(query string, options ...RequestOpti
}
q.Search = query
req, err := s.client.NewRequest("GET", "namespaces", &q, options)
req, err := s.client.NewRequest(http.MethodGet, "namespaces", &q, options)
if err != nil {
return nil, nil, err
}
@ -107,7 +108,7 @@ func (s *NamespacesService) GetNamespace(id interface{}, options ...RequestOptio
}
u := fmt.Sprintf("namespaces/%s", namespace)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -120,7 +121,7 @@ func (s *NotesService) ListIssueNotes(pid interface{}, issue int, opt *ListIssue
}
u := fmt.Sprintf("projects/%s/issues/%d/notes", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -145,7 +146,7 @@ func (s *NotesService) GetIssueNote(pid interface{}, issue, note int, options ..
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -180,7 +181,7 @@ func (s *NotesService) CreateIssueNote(pid interface{}, issue int, opt *CreateIs
}
u := fmt.Sprintf("projects/%s/issues/%d/notes", pathEscape(project), issue)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -214,7 +215,7 @@ func (s *NotesService) UpdateIssueNote(pid interface{}, issue, note int, opt *Up
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -239,7 +240,7 @@ func (s *NotesService) DeleteIssueNote(pid interface{}, issue, note int, options
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -269,7 +270,7 @@ func (s *NotesService) ListSnippetNotes(pid interface{}, snippet int, opt *ListS
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes", pathEscape(project), snippet)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -294,7 +295,7 @@ func (s *NotesService) GetSnippetNote(pid interface{}, snippet, note int, option
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -329,7 +330,7 @@ func (s *NotesService) CreateSnippetNote(pid interface{}, snippet int, opt *Crea
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes", pathEscape(project), snippet)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -363,7 +364,7 @@ func (s *NotesService) UpdateSnippetNote(pid interface{}, snippet, note int, opt
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -388,7 +389,7 @@ func (s *NotesService) DeleteSnippetNote(pid interface{}, snippet, note int, opt
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -418,7 +419,7 @@ func (s *NotesService) ListMergeRequestNotes(pid interface{}, mergeRequest int,
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -443,7 +444,7 @@ func (s *NotesService) GetMergeRequestNote(pid interface{}, mergeRequest, note i
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -477,7 +478,7 @@ func (s *NotesService) CreateMergeRequestNote(pid interface{}, mergeRequest int,
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", pathEscape(project), mergeRequest)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -511,7 +512,7 @@ func (s *NotesService) UpdateMergeRequestNote(pid interface{}, mergeRequest, not
}
u := fmt.Sprintf(
"projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -537,7 +538,7 @@ func (s *NotesService) DeleteMergeRequestNote(pid interface{}, mergeRequest, not
u := fmt.Sprintf(
"projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -566,7 +567,7 @@ func (s *NotesService) ListEpicNotes(gid interface{}, epic int, opt *ListEpicNot
}
u := fmt.Sprintf("groups/%s/epics/%d/notes", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -591,7 +592,7 @@ func (s *NotesService) GetEpicNote(gid interface{}, epic, note int, options ...R
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -624,7 +625,7 @@ func (s *NotesService) CreateEpicNote(gid interface{}, epic int, opt *CreateEpic
}
u := fmt.Sprintf("groups/%s/epics/%d/notes", pathEscape(group), epic)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -656,7 +657,7 @@ func (s *NotesService) UpdateEpicNote(gid interface{}, epic, note int, opt *Upda
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -680,7 +681,7 @@ func (s *NotesService) DeleteEpicNote(gid interface{}, epic, note int, options .
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,8 +1,25 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"errors"
"fmt"
"net/http"
)
// NotificationSettingsService handles communication with the notification settings
@ -53,7 +70,7 @@ func (ns NotificationSettings) String() string {
func (s *NotificationSettingsService) GetGlobalSettings(options ...RequestOptionFunc) (*NotificationSettings, *Response, error) {
u := "notification_settings"
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -98,7 +115,7 @@ func (s *NotificationSettingsService) UpdateGlobalSettings(opt *NotificationSett
u := "notification_settings"
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -123,7 +140,7 @@ func (s *NotificationSettingsService) GetSettingsForGroup(gid interface{}, optio
}
u := fmt.Sprintf("groups/%s/notification_settings", pathEscape(group))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -148,7 +165,7 @@ func (s *NotificationSettingsService) GetSettingsForProject(pid interface{}, opt
}
u := fmt.Sprintf("projects/%s/notification_settings", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -173,7 +190,7 @@ func (s *NotificationSettingsService) UpdateSettingsForGroup(gid interface{}, op
}
u := fmt.Sprintf("groups/%s/notification_settings", pathEscape(group))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -198,7 +215,7 @@ func (s *NotificationSettingsService) UpdateSettingsForProject(pid interface{},
}
u := fmt.Sprintf("projects/%s/notification_settings", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

168
vendor/github.com/xanzy/go-gitlab/packages.go generated vendored Normal file
View file

@ -0,0 +1,168 @@
//
// Copyright 2021, Kordian Bruck
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
// PackagesService handles communication with the packages related methods
// of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
type PackagesService struct {
client *Client
}
// Package represents a GitLab single package.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
type Package struct {
ID int `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
PackageType string `json:"package_type"`
Links *PackageLinks `json:"_links"`
CreatedAt *time.Time `json:"created_at"`
}
func (s Package) String() string {
return Stringify(s)
}
// PackageLinks holds links for itself and deleting.
type PackageLinks struct {
WebPath string `json:"web_path"`
DeleteAPIPath string `json:"delete_api_path"`
}
func (s PackageLinks) String() string {
return Stringify(s)
}
// PackageFile represents one file contained within a package.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
type PackageFile struct {
ID int `json:"id"`
PackageID int `json:"package_id"`
CreatedAt *time.Time `json:"created_at"`
FileName string `json:"file_name"`
Size int `json:"size"`
FileMD5 string `json:"file_md5"`
FileSHA1 string `json:"file_sha1"`
Pipeline *[]Pipeline `json:"pipelines"`
}
func (s PackageFile) String() string {
return Stringify(s)
}
// ListProjectPackagesOptions are the parameters available in a ListProjectPackages() Operation.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/packages.html#within-a-project
type ListProjectPackagesOptions struct {
ListOptions
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
PackageType *string `url:"package_type,omitempty" json:"package_type,omitempty"`
PackageName *string `url:"package_name,omitempty" json:"package_name,omitempty"`
IncludeVersionless *bool `url:"include_versionless,omitempty" json:"include_versionless,omitempty"`
}
// ListProjectPackages gets a list of packages in a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/packages.html#within-a-project
func (s *PackagesService) ListProjectPackages(pid interface{}, opt *ListProjectPackagesOptions, options ...RequestOptionFunc) ([]*Package, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/packages", pathEscape(project))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var ps []*Package
resp, err := s.client.Do(req, &ps)
if err != nil {
return nil, resp, err
}
return ps, resp, err
}
// ListPackageFilesOptions represents the available
// ListPackageFiles() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/packages.html#list-package-files
type ListPackageFilesOptions ListOptions
// ListPackageFiles gets a list of files that are within a package
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/packages.html#list-package-files
func (s *PackagesService) ListPackageFiles(pid interface{}, pkg int, opt *ListPackageFilesOptions, options ...RequestOptionFunc) ([]*PackageFile, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf(
"projects/%s/packages/%d/package_files",
pathEscape(project),
pkg,
)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var pfs []*PackageFile
resp, err := s.client.Do(req, &pfs)
if err != nil {
return nil, resp, err
}
return pfs, resp, err
}
// DeleteProjectPackage deletes a package in a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/packages.html#delete-a-project-package
func (s *PackagesService) DeleteProjectPackage(pid interface{}, pkg int, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/packages/%d", pathEscape(project), pkg)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -47,7 +64,7 @@ func (s *PagesDomainsService) ListPagesDomains(pid interface{}, opt *ListPagesDo
}
u := fmt.Sprintf("projects/%s/pages/domains", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -66,7 +83,7 @@ func (s *PagesDomainsService) ListPagesDomains(pid interface{}, opt *ListPagesDo
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html#list-all-pages-domains
func (s *PagesDomainsService) ListAllPagesDomains(options ...RequestOptionFunc) ([]*PagesDomain, *Response, error) {
req, err := s.client.NewRequest("GET", "pages/domains", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "pages/domains", nil, options)
if err != nil {
return nil, nil, err
}
@ -91,7 +108,7 @@ func (s *PagesDomainsService) GetPagesDomain(pid interface{}, domain string, opt
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -127,7 +144,7 @@ func (s *PagesDomainsService) CreatePagesDomain(pid interface{}, opt *CreatePage
}
u := fmt.Sprintf("projects/%s/pages/domains", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -162,7 +179,7 @@ func (s *PagesDomainsService) UpdatePagesDomain(pid interface{}, domain string,
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -187,7 +204,7 @@ func (s *PagesDomainsService) DeletePagesDomain(pid interface{}, domain string,
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -70,7 +71,7 @@ func (s *PipelineSchedulesService) ListPipelineSchedules(pid interface{}, opt *L
}
u := fmt.Sprintf("projects/%s/pipeline_schedules", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -95,7 +96,7 @@ func (s *PipelineSchedulesService) GetPipelineSchedule(pid interface{}, schedule
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -133,7 +134,7 @@ func (s *PipelineSchedulesService) CreatePipelineSchedule(pid interface{}, opt *
}
u := fmt.Sprintf("projects/%s/pipeline_schedules", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -171,7 +172,7 @@ func (s *PipelineSchedulesService) EditPipelineSchedule(pid interface{}, schedul
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -197,7 +198,7 @@ func (s *PipelineSchedulesService) TakeOwnershipOfPipelineSchedule(pid interface
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/take_ownership", pathEscape(project), schedule)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -222,7 +223,7 @@ func (s *PipelineSchedulesService) DeletePipelineSchedule(pid interface{}, sched
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -241,7 +242,7 @@ func (s *PipelineSchedulesService) RunPipelineSchedule(pid interface{}, schedule
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/play", pathEscape(project), schedule)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
@ -271,7 +272,7 @@ func (s *PipelineSchedulesService) CreatePipelineScheduleVariable(pid interface{
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables", pathEscape(project), schedule)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -306,7 +307,7 @@ func (s *PipelineSchedulesService) EditPipelineScheduleVariable(pid interface{},
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", pathEscape(project), schedule, key)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -331,7 +332,7 @@ func (s *PipelineSchedulesService) DeletePipelineScheduleVariable(pid interface{
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", pathEscape(project), schedule, key)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -45,7 +62,7 @@ func (s *PipelineTriggersService) ListPipelineTriggers(pid interface{}, opt *Lis
}
u := fmt.Sprintf("projects/%s/triggers", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -70,7 +87,7 @@ func (s *PipelineTriggersService) GetPipelineTrigger(pid interface{}, trigger in
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -103,7 +120,7 @@ func (s *PipelineTriggersService) AddPipelineTrigger(pid interface{}, opt *AddPi
}
u := fmt.Sprintf("projects/%s/triggers", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -136,7 +153,7 @@ func (s *PipelineTriggersService) EditPipelineTrigger(pid interface{}, trigger i
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -162,7 +179,7 @@ func (s *PipelineTriggersService) TakeOwnershipOfPipelineTrigger(pid interface{}
}
u := fmt.Sprintf("projects/%s/triggers/%d/take_ownership", pathEscape(project), trigger)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -187,7 +204,7 @@ func (s *PipelineTriggersService) DeletePipelineTrigger(pid interface{}, trigger
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -216,7 +233,7 @@ func (s *PipelineTriggersService) RunPipelineTrigger(pid interface{}, opt *RunPi
}
u := fmt.Sprintf("projects/%s/trigger/pipeline", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Igor Varavko
// Copyright 2021, Igor Varavko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -170,7 +171,7 @@ func (s *PipelinesService) ListProjectPipelines(pid interface{}, opt *ListProjec
}
u := fmt.Sprintf("projects/%s/pipelines", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -194,7 +195,7 @@ func (s *PipelinesService) GetPipeline(pid interface{}, pipeline int, options ..
}
u := fmt.Sprintf("projects/%s/pipelines/%d", pathEscape(project), pipeline)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -218,7 +219,7 @@ func (s *PipelinesService) GetPipelineVariables(pid interface{}, pipeline int, o
}
u := fmt.Sprintf("projects/%s/pipelines/%d/variables", pathEscape(project), pipeline)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -242,7 +243,7 @@ func (s *PipelinesService) GetPipelineTestReport(pid interface{}, pipeline int)
}
u := fmt.Sprintf("projects/%s/pipelines/%d/test_report", pathEscape(project), pipeline)
req, err := s.client.NewRequest("GET", u, nil, nil)
req, err := s.client.NewRequest(http.MethodGet, u, nil, nil)
if err != nil {
return nil, nil, err
}
@ -274,7 +275,7 @@ func (s *PipelinesService) CreatePipeline(pid interface{}, opt *CreatePipelineOp
}
u := fmt.Sprintf("projects/%s/pipeline", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -299,7 +300,7 @@ func (s *PipelinesService) RetryPipelineBuild(pid interface{}, pipeline int, opt
}
u := fmt.Sprintf("projects/%s/pipelines/%d/retry", pathEscape(project), pipeline)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -324,7 +325,7 @@ func (s *PipelinesService) CancelPipelineBuild(pid interface{}, pipeline int, op
}
u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", pathEscape(project), pipeline)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -349,7 +350,7 @@ func (s *PipelinesService) DeletePipeline(pid interface{}, pipeline int, options
}
u := fmt.Sprintf("projects/%s/pipelines/%d", pathEscape(project), pipeline)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// ProjectBadge represents a project badge.
@ -44,7 +61,7 @@ func (s *ProjectBadgesService) ListProjectBadges(pid interface{}, opt *ListProje
}
u := fmt.Sprintf("projects/%s/badges", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -69,7 +86,7 @@ func (s *ProjectBadgesService) GetProjectBadge(pid interface{}, badge int, optio
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -103,7 +120,7 @@ func (s *ProjectBadgesService) AddProjectBadge(pid interface{}, opt *AddProjectB
}
u := fmt.Sprintf("projects/%s/badges", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -137,7 +154,7 @@ func (s *ProjectBadgesService) EditProjectBadge(pid interface{}, badge int, opt
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -163,7 +180,7 @@ func (s *ProjectBadgesService) DeleteProjectBadge(pid interface{}, badge int, op
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -192,7 +209,7 @@ func (s *ProjectBadgesService) PreviewProjectBadge(pid interface{}, opt *Project
}
u := fmt.Sprintf("projects/%s/badges/render", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2019, Matej Velikonja
// Copyright 2021, Matej Velikonja
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -83,7 +84,7 @@ func (s *ProjectClustersService) ListClusters(pid interface{}, options ...Reques
}
u := fmt.Sprintf("projects/%s/clusters", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -108,7 +109,7 @@ func (s *ProjectClustersService) GetCluster(pid interface{}, cluster int, option
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -156,7 +157,7 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti
}
u := fmt.Sprintf("projects/%s/clusters/user", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -201,7 +202,7 @@ func (s *ProjectClustersService) EditCluster(pid interface{}, cluster int, opt *
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -226,7 +227,7 @@ func (s *ProjectClustersService) DeleteCluster(pid interface{}, cluster int, opt
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,8 +1,25 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"bytes"
"fmt"
"net/http"
"time"
)
@ -81,7 +98,7 @@ func (s *ProjectImportExportService) ScheduleExport(pid interface{}, opt *Schedu
}
u := fmt.Sprintf("projects/%s/export", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, err
}
@ -100,7 +117,7 @@ func (s *ProjectImportExportService) ExportStatus(pid interface{}, options ...Re
}
u := fmt.Sprintf("projects/%s/export", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -125,7 +142,7 @@ func (s *ProjectImportExportService) ExportDownload(pid interface{}, options ...
}
u := fmt.Sprintf("projects/%s/export/download", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -156,7 +173,7 @@ type ImportFileOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/project_import_export.html#import-a-file
func (s *ProjectImportExportService) ImportFile(opt *ImportFileOptions, options ...RequestOptionFunc) (*ImportStatus, *Response, error) {
req, err := s.client.NewRequest("POST", "projects/import", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "projects/import", opt, options)
if err != nil {
return nil, nil, err
}
@ -181,7 +198,7 @@ func (s *ProjectImportExportService) ImportStatus(pid interface{}, options ...Re
}
u := fmt.Sprintf("projects/%s/import", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// ProjectMembersService handles communication with the project members
@ -51,7 +52,7 @@ func (s *ProjectMembersService) ListProjectMembers(pid interface{}, opt *ListPro
}
u := fmt.Sprintf("projects/%s/members", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -78,7 +79,7 @@ func (s *ProjectMembersService) ListAllProjectMembers(pid interface{}, opt *List
}
u := fmt.Sprintf("projects/%s/members/all", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -103,7 +104,7 @@ func (s *ProjectMembersService) GetProjectMember(pid interface{}, user int, opti
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -128,7 +129,7 @@ func (s *ProjectMembersService) GetInheritedProjectMember(pid interface{}, user
}
u := fmt.Sprintf("projects/%s/members/all/%d", pathEscape(project), user)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -147,7 +148,7 @@ func (s *ProjectMembersService) GetInheritedProjectMember(pid interface{}, user
// GitLab API docs:
// https://docs.gitlab.com/ce/api/members.html#add-a-member-to-a-group-or-project
type AddProjectMemberOptions struct {
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
UserID interface{} `url:"user_id,omitempty" json:"user_id,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
ExpiresAt *string `url:"expires_at,omitempty" json:"expires_at"`
}
@ -166,7 +167,7 @@ func (s *ProjectMembersService) AddProjectMember(pid interface{}, opt *AddProjec
}
u := fmt.Sprintf("projects/%s/members", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -200,7 +201,7 @@ func (s *ProjectMembersService) EditProjectMember(pid interface{}, user int, opt
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -225,7 +226,7 @@ func (s *ProjectMembersService) DeleteProjectMember(pid interface{}, user int, o
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -56,7 +57,7 @@ func (s *ProjectMirrorService) ListProjectMirror(pid interface{}, options ...Req
}
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -93,7 +94,7 @@ func (s *ProjectMirrorService) AddProjectMirror(pid interface{}, opt *AddProject
}
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -129,7 +130,7 @@ func (s *ProjectMirrorService) EditProjectMirror(pid interface{}, mirror int, op
}
u := fmt.Sprintf("projects/%s/remote_mirrors/%d", pathEscape(project), mirror)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"bytes"
"fmt"
"net/http"
)
// ProjectSnippetsService handles communication with the project snippets
@ -44,7 +45,7 @@ func (s *ProjectSnippetsService) ListSnippets(pid interface{}, opt *ListProjectS
}
u := fmt.Sprintf("projects/%s/snippets", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -69,7 +70,7 @@ func (s *ProjectSnippetsService) GetSnippet(pid interface{}, snippet int, option
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -107,7 +108,7 @@ func (s *ProjectSnippetsService) CreateSnippet(pid interface{}, opt *CreateProje
}
u := fmt.Sprintf("projects/%s/snippets", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -145,7 +146,7 @@ func (s *ProjectSnippetsService) UpdateSnippet(pid interface{}, snippet int, opt
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -172,7 +173,7 @@ func (s *ProjectSnippetsService) DeleteSnippet(pid interface{}, snippet int, opt
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -191,7 +192,7 @@ func (s *ProjectSnippetsService) SnippetContent(pid interface{}, snippet int, op
}
u := fmt.Sprintf("projects/%s/snippets/%d/raw", pathEscape(project), snippet)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Patrick Webster
// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -65,7 +66,7 @@ func (s *ProjectVariablesService) ListVariables(pid interface{}, opt *ListProjec
}
u := fmt.Sprintf("projects/%s/variables", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -90,7 +91,7 @@ func (s *ProjectVariablesService) GetVariable(pid interface{}, key string, optio
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -129,7 +130,7 @@ func (s *ProjectVariablesService) CreateVariable(pid interface{}, opt *CreatePro
}
u := fmt.Sprintf("projects/%s/variables", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -167,7 +168,7 @@ func (s *ProjectVariablesService) UpdateVariable(pid interface{}, key string, op
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -192,7 +193,7 @@ func (s *ProjectVariablesService) RemoveVariable(pid interface{}, key string, op
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import (
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"time"
)
@ -38,71 +39,74 @@ type ProjectsService struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
type Project struct {
ID int `json:"id"`
Description string `json:"description"`
DefaultBranch string `json:"default_branch"`
Public bool `json:"public"`
Visibility VisibilityValue `json:"visibility"`
SSHURLToRepo string `json:"ssh_url_to_repo"`
HTTPURLToRepo string `json:"http_url_to_repo"`
WebURL string `json:"web_url"`
ReadmeURL string `json:"readme_url"`
TagList []string `json:"tag_list"`
Owner *User `json:"owner"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
IssuesEnabled bool `json:"issues_enabled"`
OpenIssuesCount int `json:"open_issues_count"`
MergeRequestsEnabled bool `json:"merge_requests_enabled"`
ApprovalsBeforeMerge int `json:"approvals_before_merge"`
JobsEnabled bool `json:"jobs_enabled"`
WikiEnabled bool `json:"wiki_enabled"`
SnippetsEnabled bool `json:"snippets_enabled"`
ResolveOutdatedDiffDiscussions bool `json:"resolve_outdated_diff_discussions"`
ContainerRegistryEnabled bool `json:"container_registry_enabled"`
CreatedAt *time.Time `json:"created_at,omitempty"`
LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
CreatorID int `json:"creator_id"`
Namespace *ProjectNamespace `json:"namespace"`
ImportStatus string `json:"import_status"`
ImportError string `json:"import_error"`
Permissions *Permissions `json:"permissions"`
MarkedForDeletionAt *ISOTime `json:"marked_for_deletion_at"`
Archived bool `json:"archived"`
AvatarURL string `json:"avatar_url"`
SharedRunnersEnabled bool `json:"shared_runners_enabled"`
ForksCount int `json:"forks_count"`
StarCount int `json:"star_count"`
RunnersToken string `json:"runners_token"`
PublicBuilds bool `json:"public_builds"`
AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"`
OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"`
OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"`
LFSEnabled bool `json:"lfs_enabled"`
RequestAccessEnabled bool `json:"request_access_enabled"`
MergeMethod MergeMethodValue `json:"merge_method"`
ForkedFromProject *ForkParent `json:"forked_from_project"`
Mirror bool `json:"mirror"`
MirrorUserID int `json:"mirror_user_id"`
MirrorTriggerBuilds bool `json:"mirror_trigger_builds"`
OnlyMirrorProtectedBranches bool `json:"only_mirror_protected_branches"`
MirrorOverwritesDivergedBranches bool `json:"mirror_overwrites_diverged_branches"`
PackagesEnabled bool `json:"packages_enabled"`
ServiceDeskEnabled bool `json:"service_desk_enabled"`
ServiceDeskAddress string `json:"service_desk_address"`
IssuesAccessLevel AccessControlValue `json:"issues_access_level"`
RepositoryAccessLevel AccessControlValue `json:"repository_access_level"`
MergeRequestsAccessLevel AccessControlValue `json:"merge_requests_access_level"`
ForkingAccessLevel AccessControlValue `json:"forking_access_level"`
WikiAccessLevel AccessControlValue `json:"wiki_access_level"`
BuildsAccessLevel AccessControlValue `json:"builds_access_level"`
SnippetsAccessLevel AccessControlValue `json:"snippets_access_level"`
PagesAccessLevel AccessControlValue `json:"pages_access_level"`
AutocloseReferencedIssues bool `json:"autoclose_referenced_issues"`
CIForwardDeploymentEnabled bool `json:"ci_forward_deployment_enabled"`
ID int `json:"id"`
Description string `json:"description"`
DefaultBranch string `json:"default_branch"`
Public bool `json:"public"`
Visibility VisibilityValue `json:"visibility"`
SSHURLToRepo string `json:"ssh_url_to_repo"`
HTTPURLToRepo string `json:"http_url_to_repo"`
WebURL string `json:"web_url"`
ReadmeURL string `json:"readme_url"`
TagList []string `json:"tag_list"`
Owner *User `json:"owner"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
IssuesEnabled bool `json:"issues_enabled"`
OpenIssuesCount int `json:"open_issues_count"`
MergeRequestsEnabled bool `json:"merge_requests_enabled"`
ApprovalsBeforeMerge int `json:"approvals_before_merge"`
JobsEnabled bool `json:"jobs_enabled"`
WikiEnabled bool `json:"wiki_enabled"`
SnippetsEnabled bool `json:"snippets_enabled"`
ResolveOutdatedDiffDiscussions bool `json:"resolve_outdated_diff_discussions"`
ContainerExpirationPolicy *ContainerExpirationPolicy `json:"container_expiration_policy,omitempty"`
ContainerRegistryEnabled bool `json:"container_registry_enabled"`
CreatedAt *time.Time `json:"created_at,omitempty"`
LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
CreatorID int `json:"creator_id"`
Namespace *ProjectNamespace `json:"namespace"`
ImportStatus string `json:"import_status"`
ImportError string `json:"import_error"`
Permissions *Permissions `json:"permissions"`
MarkedForDeletionAt *ISOTime `json:"marked_for_deletion_at"`
EmptyRepo bool `json:"empty_repo"`
Archived bool `json:"archived"`
AvatarURL string `json:"avatar_url"`
SharedRunnersEnabled bool `json:"shared_runners_enabled"`
ForksCount int `json:"forks_count"`
StarCount int `json:"star_count"`
RunnersToken string `json:"runners_token"`
PublicBuilds bool `json:"public_builds"`
AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"`
OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"`
OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"`
LFSEnabled bool `json:"lfs_enabled"`
RequestAccessEnabled bool `json:"request_access_enabled"`
MergeMethod MergeMethodValue `json:"merge_method"`
ForkedFromProject *ForkParent `json:"forked_from_project"`
Mirror bool `json:"mirror"`
MirrorUserID int `json:"mirror_user_id"`
MirrorTriggerBuilds bool `json:"mirror_trigger_builds"`
OnlyMirrorProtectedBranches bool `json:"only_mirror_protected_branches"`
MirrorOverwritesDivergedBranches bool `json:"mirror_overwrites_diverged_branches"`
PackagesEnabled bool `json:"packages_enabled"`
ServiceDeskEnabled bool `json:"service_desk_enabled"`
ServiceDeskAddress string `json:"service_desk_address"`
IssuesAccessLevel AccessControlValue `json:"issues_access_level"`
RepositoryAccessLevel AccessControlValue `json:"repository_access_level"`
MergeRequestsAccessLevel AccessControlValue `json:"merge_requests_access_level"`
ForkingAccessLevel AccessControlValue `json:"forking_access_level"`
WikiAccessLevel AccessControlValue `json:"wiki_access_level"`
BuildsAccessLevel AccessControlValue `json:"builds_access_level"`
SnippetsAccessLevel AccessControlValue `json:"snippets_access_level"`
PagesAccessLevel AccessControlValue `json:"pages_access_level"`
OperationsAccessLevel AccessControlValue `json:"operations_access_level"`
AutocloseReferencedIssues bool `json:"autoclose_referenced_issues"`
CIForwardDeploymentEnabled bool `json:"ci_forward_deployment_enabled"`
SharedWithGroups []struct {
GroupID int `json:"group_id"`
GroupName string `json:"group_name"`
@ -116,6 +120,17 @@ type Project struct {
ComplianceFrameworks []string `json:"compliance_frameworks"`
}
// ContainerExpirationPolicy represents the container expiration policy.
type ContainerExpirationPolicy struct {
Cadence string `json:"cadence"`
KeepN int `json:"keep_n"`
OlderThan string `json:"older_than"`
NameRegexDelete string `json:"name_regex_delete"`
NameRegexKeep string `json:"name_regex_keep"`
Enabled bool `json:"enabled"`
NextRunAt *time.Time `json:"next_run_at"`
}
// Repository represents a repository.
type Repository struct {
Name string `json:"name"`
@ -257,7 +272,7 @@ type ListProjectsOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-projects
func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...RequestOptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "projects", opt, options)
if err != nil {
return nil, nil, err
}
@ -282,7 +297,7 @@ func (s *ProjectsService) ListUserProjects(uid interface{}, opt *ListProjectsOpt
}
u := fmt.Sprintf("users/%s/projects", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -325,7 +340,7 @@ func (s *ProjectsService) ListProjectsUsers(pid interface{}, opt *ListProjectUse
}
u := fmt.Sprintf("projects/%s/users", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -354,7 +369,7 @@ func (s *ProjectsService) GetProjectLanguages(pid interface{}, options ...Reques
}
u := fmt.Sprintf("projects/%s/languages", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -389,7 +404,7 @@ func (s *ProjectsService) GetProject(pid interface{}, opt *GetProjectOptions, op
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -450,7 +465,7 @@ func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEvent
}
u := fmt.Sprintf("projects/%s/events", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -468,55 +483,57 @@ func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEvent
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#create-project
type CreateProjectOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"`
NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
PrintingMergeRequestLinkEnabled *bool `url:"printing_merge_request_link_enabled,omitempty" json:"printing_merge_request_link_enabled,omitempty"`
BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
InitializeWithReadme *bool `url:"initialize_with_readme,omitempty" json:"initialize_with_readme,omitempty"`
TemplateName *string `url:"template_name,omitempty" json:"template_name,omitempty"`
TemplateProjectID *int `url:"template_project_id,omitempty" json:"template_project_id,omitempty"`
UseCustomTemplate *bool `url:"use_custom_template,omitempty" json:"use_custom_template,omitempty"`
GroupWithProjectTemplatesID *int `url:"group_with_project_templates_id,omitempty" json:"group_with_project_templates_id,omitempty"`
PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"`
NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
OperationsAccessLevel *AccessControlValue `url:"operations_access_level,omitempty" json:"operations_access_level,omitempty"`
EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
ContainerExpirationPolicyAttributes *ContainerExpirationPolicyAttributes `url:"container_expiration_policy_attributes,omitempty" json:"container_expiration_policy_attributes,omitempty"`
ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
PrintingMergeRequestLinkEnabled *bool `url:"printing_merge_request_link_enabled,omitempty" json:"printing_merge_request_link_enabled,omitempty"`
BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
InitializeWithReadme *bool `url:"initialize_with_readme,omitempty" json:"initialize_with_readme,omitempty"`
TemplateName *string `url:"template_name,omitempty" json:"template_name,omitempty"`
TemplateProjectID *int `url:"template_project_id,omitempty" json:"template_project_id,omitempty"`
UseCustomTemplate *bool `url:"use_custom_template,omitempty" json:"use_custom_template,omitempty"`
GroupWithProjectTemplatesID *int `url:"group_with_project_templates_id,omitempty" json:"group_with_project_templates_id,omitempty"`
PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
// Deprecated members
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
@ -526,11 +543,34 @@ type CreateProjectOptions struct {
SnippetsEnabled *bool `url:"snippets_enabled,omitempty" json:"snippets_enabled,omitempty"`
}
// ContainerExpirationPolicyAttributes represents the available container
// expiration policy attributes.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#create-project
type ContainerExpirationPolicyAttributes struct {
Cadence *string `url:"cadence,omitempty" json:"cadence,omitempty"`
KeepN *int `url:"keep_n,omitempty" json:"keep_n,omitempty"`
OlderThan *string `url:"older_than,omitempty" json:"older_than,omitempty"`
NameRegexDelete *string `url:"name_regex_delete,omitempty" json:"name_regex_delete,omitempty"`
NameRegexKeep *string `url:"name_regex_keep,omitempty" json:"name_regex_keep,omitempty"`
Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"`
// Deprecated members
NameRegex *string `url:"name_regex,omitempty" json:"name_regex,omitempty"`
}
// CreateProject creates a new project owned by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#create-project
func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
req, err := s.client.NewRequest("POST", "projects", opt, options)
if opt.ContainerExpirationPolicyAttributes != nil {
// This is needed to satisfy the API. Should be deleted
// when NameRegex is removed (it's now deprecated).
opt.ContainerExpirationPolicyAttributes.NameRegex =
opt.ContainerExpirationPolicyAttributes.NameRegexDelete
}
req, err := s.client.NewRequest(http.MethodPost, "projects", opt, options)
if err != nil {
return nil, nil, err
}
@ -557,9 +597,15 @@ type CreateProjectForUserOptions CreateProjectOptions
// GitLab API docs:
// https://docs.gitlab.com/ce/api/projects.html#create-project-for-user
func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUserOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
u := fmt.Sprintf("projects/user/%d", user)
if opt.ContainerExpirationPolicyAttributes != nil {
// This is needed to satisfy the API. Should be deleted
// when NameRegex is removed (it's now deprecated).
opt.ContainerExpirationPolicyAttributes.NameRegex =
opt.ContainerExpirationPolicyAttributes.NameRegexDelete
}
req, err := s.client.NewRequest("POST", u, opt, options)
u := fmt.Sprintf("projects/user/%d", user)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -577,52 +623,54 @@ func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUs
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
type EditProjectOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
CIDefaultGitDepth *int `url:"ci_default_git_depth,omitempty" json:"ci_default_git_depth,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
MirrorUserID *int `url:"mirror_user_id,omitempty" json:"mirror_user_id,omitempty"`
MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
OnlyMirrorProtectedBranches *bool `url:"only_mirror_protected_branches,omitempty" json:"only_mirror_protected_branches,omitempty"`
MirrorOverwritesDivergedBranches *bool `url:"mirror_overwrites_diverged_branches,omitempty" json:"mirror_overwrites_diverged_branches,omitempty"`
PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
OperationsAccessLevel *AccessControlValue `url:"operations_access_level,omitempty" json:"operations_access_level,omitempty"`
EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
ContainerExpirationPolicyAttributes *ContainerExpirationPolicyAttributes `url:"container_expiration_policy_attributes,omitempty" json:"container_expiration_policy_attributes,omitempty"`
ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
CIDefaultGitDepth *int `url:"ci_default_git_depth,omitempty" json:"ci_default_git_depth,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
MirrorUserID *int `url:"mirror_user_id,omitempty" json:"mirror_user_id,omitempty"`
MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
OnlyMirrorProtectedBranches *bool `url:"only_mirror_protected_branches,omitempty" json:"only_mirror_protected_branches,omitempty"`
MirrorOverwritesDivergedBranches *bool `url:"mirror_overwrites_diverged_branches,omitempty" json:"mirror_overwrites_diverged_branches,omitempty"`
PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
// Deprecated members
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
@ -636,13 +684,20 @@ type EditProjectOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
if opt.ContainerExpirationPolicyAttributes != nil {
// This is needed to satisfy the API. Should be deleted
// when NameRegex is removed (it's now deprecated).
opt.ContainerExpirationPolicyAttributes.NameRegex =
opt.ContainerExpirationPolicyAttributes.NameRegexDelete
}
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -676,7 +731,7 @@ func (s *ProjectsService) ForkProject(pid interface{}, opt *ForkProjectOptions,
}
u := fmt.Sprintf("projects/%s/fork", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -701,7 +756,7 @@ func (s *ProjectsService) StarProject(pid interface{}, options ...RequestOptionF
}
u := fmt.Sprintf("projects/%s/star", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -726,7 +781,7 @@ func (s *ProjectsService) UnstarProject(pid interface{}, options ...RequestOptio
}
u := fmt.Sprintf("projects/%s/unstar", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -752,7 +807,7 @@ func (s *ProjectsService) ArchiveProject(pid interface{}, options ...RequestOpti
}
u := fmt.Sprintf("projects/%s/archive", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -778,7 +833,7 @@ func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...RequestOp
}
u := fmt.Sprintf("projects/%s/unarchive", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -803,7 +858,7 @@ func (s *ProjectsService) DeleteProject(pid interface{}, options ...RequestOptio
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -830,7 +885,7 @@ func (s *ProjectsService) ShareProjectWithGroup(pid interface{}, opt *ShareWithG
}
u := fmt.Sprintf("projects/%s/share", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, err
}
@ -848,7 +903,7 @@ func (s *ProjectsService) DeleteSharedProjectFromGroup(pid interface{}, groupID
}
u := fmt.Sprintf("projects/%s/share/%d", pathEscape(project), groupID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -913,7 +968,7 @@ func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHook
}
u := fmt.Sprintf("projects/%s/hooks", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -938,7 +993,7 @@ func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...R
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -985,7 +1040,7 @@ func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOpt
}
u := fmt.Sprintf("projects/%s/hooks", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1032,7 +1087,7 @@ func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditPr
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1058,7 +1113,7 @@ func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options .
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -1086,7 +1141,7 @@ type ProjectForkRelation struct {
func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options ...RequestOptionFunc) (*ProjectForkRelation, *Response, error) {
u := fmt.Sprintf("projects/%d/fork/%d", pid, fork)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -1107,7 +1162,7 @@ func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options .
func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("projects/%d/fork", pid)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -1162,7 +1217,7 @@ func (s *ProjectsService) UploadFile(pid interface{}, file string, options ...Re
req.Body = ioutil.NopCloser(b)
req.ContentLength = int64(b.Len())
req.Header.Set("Content-Type", w.FormDataContentType())
req.Method = "POST"
req.Method = http.MethodPost
uf := &ProjectFile{}
resp, err := s.client.Do(req, uf)
@ -1184,7 +1239,7 @@ func (s *ProjectsService) ListProjectForks(pid interface{}, opt *ListProjectsOpt
}
u := fmt.Sprintf("projects/%s/forks", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1230,7 +1285,7 @@ func (s *ProjectsService) GetProjectPushRules(pid interface{}, options ...Reques
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -1274,7 +1329,7 @@ func (s *ProjectsService) AddProjectPushRule(pid interface{}, opt *AddProjectPus
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1318,7 +1373,7 @@ func (s *ProjectsService) EditProjectPushRule(pid interface{}, opt *EditProjectP
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1345,7 +1400,7 @@ func (s *ProjectsService) DeleteProjectPushRule(pid interface{}, options ...Requ
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -1378,7 +1433,7 @@ func (s *ProjectsService) GetApprovalConfiguration(pid interface{}, options ...R
}
u := fmt.Sprintf("projects/%s/approvals", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -1416,7 +1471,7 @@ func (s *ProjectsService) ChangeApprovalConfiguration(pid interface{}, opt *Chan
}
u := fmt.Sprintf("projects/%s/approvals", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1441,7 +1496,7 @@ func (s *ProjectsService) GetProjectApprovalRules(pid interface{}, options ...Re
}
u := fmt.Sprintf("projects/%s/approval_rules", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -1479,7 +1534,7 @@ func (s *ProjectsService) CreateProjectApprovalRule(pid interface{}, opt *Create
}
u := fmt.Sprintf("projects/%s/approval_rules", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1517,7 +1572,7 @@ func (s *ProjectsService) UpdateProjectApprovalRule(pid interface{}, approvalRul
}
u := fmt.Sprintf("projects/%s/approval_rules/%d", pathEscape(project), approvalRule)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1542,7 +1597,7 @@ func (s *ProjectsService) DeleteProjectApprovalRule(pid interface{}, approvalRul
}
u := fmt.Sprintf("projects/%s/approval_rules/%d", pathEscape(project), approvalRule)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -1571,7 +1626,7 @@ func (s *ProjectsService) ChangeAllowedApprovers(pid interface{}, opt *ChangeAll
}
u := fmt.Sprintf("projects/%s/approvers", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -1596,7 +1651,7 @@ func (s *ProjectsService) StartMirroringProject(pid interface{}, options ...Requ
}
u := fmt.Sprintf("projects/%s/mirror/pull", pathEscape(project))
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
@ -1626,7 +1681,7 @@ func (s *ProjectsService) TransferProject(pid interface{}, opt *TransferProjectO
}
u := fmt.Sprintf("projects/%s/transfer", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen, Michael Lihs
// Copyright 2021, Sander van Harmelen, Michael Lihs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -30,18 +31,6 @@ type ProtectedBranchesService struct {
client *Client
}
// BranchAccessDescription represents the access description for a protected
// branch.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api
type BranchAccessDescription struct {
AccessLevel AccessLevelValue `json:"access_level"`
UserID int `json:"user_id"`
GroupID int `json:"group_id"`
AccessLevelDescription string `json:"access_level_description"`
}
// ProtectedBranch represents a protected branch.
//
// GitLab API docs:
@ -55,6 +44,18 @@ type ProtectedBranch struct {
CodeOwnerApprovalRequired bool `json:"code_owner_approval_required"`
}
// BranchAccessDescription represents the access description for a protected
// branch.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api
type BranchAccessDescription struct {
AccessLevel AccessLevelValue `json:"access_level"`
AccessLevelDescription string `json:"access_level_description"`
UserID int `json:"user_id"`
GroupID int `json:"group_id"`
}
// ListProtectedBranchesOptions represents the available ListProtectedBranches()
// options.
//
@ -73,7 +74,7 @@ func (s *ProtectedBranchesService) ListProtectedBranches(pid interface{}, opt *L
}
u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -98,7 +99,7 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -118,21 +119,21 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches
type ProtectRepositoryBranchesOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"`
MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"`
UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"`
AllowedToPush []*ProtectBranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
AllowedToMerge []*ProtectBranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"`
AllowedToUnprotect []*ProtectBranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"`
CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"`
MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"`
UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"`
AllowedToPush []*BranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
AllowedToMerge []*BranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"`
AllowedToUnprotect []*BranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"`
CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"`
}
// ProtectBranchPermissionOptions represents a branch permission option.
// BranchPermissionOptions represents a branch permission option.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches
type ProtectBranchPermissionOptions struct {
type BranchPermissionOptions struct {
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
@ -150,7 +151,7 @@ func (s *ProtectedBranchesService) ProtectRepositoryBranches(pid interface{}, op
}
u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -176,7 +177,7 @@ func (s *ProtectedBranchesService) UnprotectRepositoryBranches(pid interface{},
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -204,7 +205,7 @@ func (s *ProtectedBranchesService) RequireCodeOwnerApprovals(pid interface{}, br
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("PATCH", u, opt, options)
req, err := s.client.NewRequest(http.MethodPatch, u, opt, options)
if err != nil {
return nil, err
}

View file

@ -0,0 +1,176 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// ProtectedEnvironmentsService handles communication with the protected
// environment methods of the GitLab API.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html
type ProtectedEnvironmentsService struct {
client *Client
}
// ProtectedEnvironment represents a protected environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html
type ProtectedEnvironment struct {
Name string `json:"name"`
DeployAccessLevels []*EnvironmentAccessDescription `json:"deploy_access_levels"`
}
// EnvironmentAccessDescription represents the access decription for a protected
// environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html
type EnvironmentAccessDescription struct {
AccessLevel AccessLevelValue `json:"access_level"`
AccessLevelDescription string `json:"access_level_description"`
UserID int `json:"user_id"`
GroupID int `json:"group_id"`
}
// ListProtectedEnvironmentsOptions represents the available
// ListProtectedEnvironments() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#list-protected-environments
type ListProtectedEnvironmentsOptions ListOptions
// ListProtectedEnvironments returns a list of protected environments from a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#list-protected-environments
func (s *ProtectedEnvironmentsService) ListProtectedEnvironments(pid interface{}, opt *ListProtectedEnvironmentsOptions, options ...RequestOptionFunc) ([]*ProtectedEnvironment, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/protected_environments", pathEscape(project))
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var pes []*ProtectedEnvironment
resp, err := s.client.Do(req, &pes)
if err != nil {
return nil, resp, err
}
return pes, resp, err
}
// GetProtectedEnvironment returns a single protected environment or wildcard protected environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#get-a-single-protected-environment-or-wildcard-protected-environment
func (s *ProtectedEnvironmentsService) GetProtectedEnvironment(pid interface{}, environment string, options ...RequestOptionFunc) (*ProtectedEnvironment, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/protected_environments/%s", pathEscape(project), pathEscape(environment))
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
pe := new(ProtectedEnvironment)
resp, err := s.client.Do(req, pe)
if err != nil {
return nil, resp, err
}
return pe, resp, err
}
// ProtectRepositoryEnvironmentsOptions represents the available
// ProtectRepositoryEnvironments() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
type ProtectRepositoryEnvironmentsOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
DeployAccessLevels []*EnvironmentAccessOptions `url:"deploy_access_levels,omitempty" json:"deploy_access_levels,omitempty"`
}
// EnvironmentAccessOptions represents the options for an access decription for
// a protected environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
type EnvironmentAccessOptions struct {
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
}
// ProtectRepositoryEnvironments protects a single repository environment or several project
// repository environments using a wildcard protected environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
func (s *ProtectedEnvironmentsService) ProtectRepositoryEnvironments(pid interface{}, opt *ProtectRepositoryEnvironmentsOptions, options ...RequestOptionFunc) (*ProtectedEnvironment, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/protected_environments", pathEscape(project))
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
pe := new(ProtectedEnvironment)
resp, err := s.client.Do(req, pe)
if err != nil {
return nil, resp, err
}
return pe, resp, err
}
// UnprotectEnvironment unprotects the given protected environment or wildcard
// protected environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#unprotect-repository-environments
func (s *ProtectedEnvironmentsService) UnprotectEnvironment(pid interface{}, environment string, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/protected_environments/%s", pathEscape(project), pathEscape(environment))
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// ProtectedTagsService handles communication with the protected tag methods
@ -49,7 +66,7 @@ func (s *ProtectedTagsService) ListProtectedTags(pid interface{}, opt *ListProte
}
u := fmt.Sprintf("projects/%s/protected_tags", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -74,7 +91,7 @@ func (s *ProtectedTagsService) GetProtectedTag(pid interface{}, tag string, opti
}
u := fmt.Sprintf("projects/%s/protected_tags/%s", pathEscape(project), pathEscape(tag))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -110,7 +127,7 @@ func (s *ProtectedTagsService) ProtectRepositoryTags(pid interface{}, opt *Prote
}
u := fmt.Sprintf("projects/%s/protected_tags", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -136,7 +153,7 @@ func (s *ProtectedTagsService) UnprotectRepositoryTags(pid interface{}, tag stri
}
u := fmt.Sprintf("projects/%s/protected_tags/%s", pathEscape(project), pathEscape(tag))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -17,11 +34,14 @@ type ContainerRegistryService struct {
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryRepository struct {
ID int `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Location string `json:"location"`
CreatedAt *time.Time `json:"created_at"`
ID int `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Location string `json:"location"`
CreatedAt *time.Time `json:"created_at"`
CreatePolicyStartedAt *time.Time `json:"cleanup_policy_started_at"`
TagsCount int `json:"tags_count"`
Tags []*RegistryRepositoryTag `json:"tags"`
}
func (s RegistryRepository) String() string {
@ -51,7 +71,11 @@ func (s RegistryRepositoryTag) String() string {
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories
type ListRegistryRepositoriesOptions ListOptions
type ListRegistryRepositoriesOptions struct {
ListOptions
Tags *bool `url:"tags,omitempty" json:"tags,omitempty"`
TagsCount *bool `url:"tags_count,omitempty" json:"tags_count,omitempty"`
}
// ListRegistryRepositories gets a list of registry repositories in a project.
//
@ -64,7 +88,7 @@ func (s *ContainerRegistryService) ListRegistryRepositories(pid interface{}, opt
}
u := fmt.Sprintf("projects/%s/registry/repositories", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -89,7 +113,7 @@ func (s *ContainerRegistryService) DeleteRegistryRepository(pid interface{}, rep
}
u := fmt.Sprintf("projects/%s/registry/repositories/%d", pathEscape(project), repository)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -118,7 +142,7 @@ func (s *ContainerRegistryService) ListRegistryRepositoryTags(pid interface{}, r
repository,
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -147,7 +171,7 @@ func (s *ContainerRegistryService) GetRegistryRepositoryTagDetail(pid interface{
tagName,
)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -176,7 +200,7 @@ func (s *ContainerRegistryService) DeleteRegistryRepositoryTag(pid interface{},
tagName,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -214,7 +238,7 @@ func (s *ContainerRegistryService) DeleteRegistryRepositoryTags(pid interface{},
repository,
)
req, err := s.client.NewRequest("DELETE", u, opt, options)
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// ReleaseLinksService handles communication with the release link methods
@ -37,7 +54,7 @@ func (s *ReleaseLinksService) ListReleaseLinks(pid interface{}, tagName string,
}
u := fmt.Sprintf("projects/%s/releases/%s/assets/links", pathEscape(project), tagName)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -64,7 +81,7 @@ func (s *ReleaseLinksService) GetReleaseLink(pid interface{}, tagName string, li
tagName,
link)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -96,7 +113,7 @@ func (s *ReleaseLinksService) CreateReleaseLink(pid interface{}, tagName string,
}
u := fmt.Sprintf("projects/%s/releases/%s/assets/links", pathEscape(project), tagName)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -133,7 +150,7 @@ func (s *ReleaseLinksService) UpdateReleaseLink(pid interface{}, tagName string,
tagName,
link)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -161,7 +178,7 @@ func (s *ReleaseLinksService) DeleteReleaseLink(pid interface{}, tagName string,
link,
)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -59,7 +76,7 @@ func (s *ReleasesService) ListReleases(pid interface{}, opt *ListReleasesOptions
}
u := fmt.Sprintf("projects/%s/releases", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -84,7 +101,7 @@ func (s *ReleasesService) GetRelease(pid interface{}, tagName string, options ..
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -140,7 +157,7 @@ func (s *ReleasesService) CreateRelease(pid interface{}, opts *CreateReleaseOpti
}
u := fmt.Sprintf("projects/%s/releases", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opts, options)
req, err := s.client.NewRequest(http.MethodPost, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -176,7 +193,7 @@ func (s *ReleasesService) UpdateRelease(pid interface{}, tagName string, opts *U
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
req, err := s.client.NewRequest("PUT", u, opts, options)
req, err := s.client.NewRequest(http.MethodPut, u, opts, options)
if err != nil {
return nil, nil, err
}
@ -201,7 +218,7 @@ func (s *ReleasesService) DeleteRelease(pid interface{}, tagName string, options
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io"
"net/http"
"net/url"
)
@ -68,7 +69,7 @@ func (s *RepositoriesService) ListTree(pid interface{}, opt *ListTreeOptions, op
}
u := fmt.Sprintf("projects/%s/repository/tree", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -94,7 +95,7 @@ func (s *RepositoriesService) Blob(pid interface{}, sha string, options ...Reque
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -119,7 +120,7 @@ func (s *RepositoriesService) RawBlobContent(pid interface{}, sha string, option
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s/raw", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -158,7 +159,7 @@ func (s *RepositoriesService) Archive(pid interface{}, opt *ArchiveOptions, opti
u = fmt.Sprintf("%s.%s", u, *opt.Format)
}
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -189,7 +190,7 @@ func (s *RepositoriesService) StreamArchive(pid interface{}, w io.Writer, opt *A
u = fmt.Sprintf("%s.%s", u, *opt.Format)
}
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, err
}
@ -234,7 +235,7 @@ func (s *RepositoriesService) Compare(pid interface{}, opt *CompareOptions, opti
}
u := fmt.Sprintf("projects/%s/repository/compare", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -282,7 +283,7 @@ func (s *RepositoriesService) Contributors(pid interface{}, opt *ListContributor
}
u := fmt.Sprintf("projects/%s/repository/contributors", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -316,7 +317,7 @@ func (s *RepositoriesService) MergeBase(pid interface{}, opt *MergeBaseOptions,
}
u := fmt.Sprintf("projects/%s/repository/merge_base", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"bytes"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@ -76,7 +77,7 @@ func (s *RepositoryFilesService) GetFile(pid interface{}, fileName string, opt *
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -114,7 +115,7 @@ func (s *RepositoryFilesService) GetFileMetaData(pid interface{}, fileName strin
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("HEAD", u, opt, options)
req, err := s.client.NewRequest(http.MethodHead, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -191,7 +192,7 @@ func (s *RepositoryFilesService) GetFileBlame(pid interface{}, file string, opt
url.PathEscape(file),
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -228,7 +229,7 @@ func (s *RepositoryFilesService) GetRawFile(pid interface{}, fileName string, op
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -283,7 +284,7 @@ func (s *RepositoryFilesService) CreateFile(pid interface{}, fileName string, op
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -327,7 +328,7 @@ func (s *RepositoryFilesService) UpdateFile(pid interface{}, fileName string, op
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -369,7 +370,7 @@ func (s *RepositoryFilesService) DeleteFile(pid interface{}, fileName string, op
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("DELETE", u, opt, options)
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}

View file

@ -1,3 +1,19 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -77,7 +78,7 @@ func (s *ResourceLabelEventsService) ListIssueLabelEvents(pid interface{}, issue
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_label_events", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -102,7 +103,7 @@ func (s *ResourceLabelEventsService) GetIssueLabelEvent(pid interface{}, issue i
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_label_events/%d", pathEscape(project), issue, event)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -128,7 +129,7 @@ func (s *ResourceLabelEventsService) ListGroupEpicLabelEvents(gid interface{}, e
}
u := fmt.Sprintf("groups/%s/epics/%d/resource_label_events", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -153,7 +154,7 @@ func (s *ResourceLabelEventsService) GetGroupEpicLabelEvent(gid interface{}, epi
}
u := fmt.Sprintf("groups/%s/epics/%d/resource_label_events/%d", pathEscape(group), epic, event)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -179,7 +180,7 @@ func (s *ResourceLabelEventsService) ListMergeLabelEvents(pid interface{}, reque
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_label_events", pathEscape(project), request)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -204,7 +205,7 @@ func (s *ResourceLabelEventsService) GetMergeRequestLabelEvent(pid interface{},
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_label_events/%d", pathEscape(project), request, event)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -0,0 +1,154 @@
//
// Copyright 2021, Matthias Simon
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
"time"
)
// ResourceStateEventsService handles communication with the event related
// methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_state_events.html
type ResourceStateEventsService struct {
client *Client
}
// StateEvent represents a resource state event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_state_events.html
type StateEvent struct {
ID int `json:"id"`
User *BasicUser `json:"user"`
CreatedAt *time.Time `json:"created_at"`
ResourceType string `json:"resource_type"`
ResourceID int `json:"resource_id"`
State EventTypeValue `json:"state"`
}
// ListStateEventsOptions represents the options for all resource state events
// list methods.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-issue-state-events
type ListStateEventsOptions struct {
ListOptions
}
// ListIssueStateEvents retrieves resource state events for the specified
// project and issue.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-issue-state-events
func (s *ResourceStateEventsService) ListIssueStateEvents(pid interface{}, issue int, opt *ListStateEventsOptions, options ...RequestOptionFunc) ([]*StateEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_state_events", pathEscape(project), issue)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var ses []*StateEvent
resp, err := s.client.Do(req, &ses)
if err != nil {
return nil, resp, err
}
return ses, resp, err
}
// GetIssueStateEvent gets a single issue-state-event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_state_events.html#get-single-issue-state-event
func (s *ResourceStateEventsService) GetIssueStateEvent(pid interface{}, issue int, event int, options ...RequestOptionFunc) (*StateEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_state_events/%d", pathEscape(project), issue, event)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
se := new(StateEvent)
resp, err := s.client.Do(req, se)
if err != nil {
return nil, resp, err
}
return se, resp, err
}
// ListMergeStateEvents retrieves resource state events for the specified
// project and merge request.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-merge-request-state-events
func (s *ResourceStateEventsService) ListMergeStateEvents(pid interface{}, request int, opt *ListStateEventsOptions, options ...RequestOptionFunc) ([]*StateEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_state_events", pathEscape(project), request)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var ses []*StateEvent
resp, err := s.client.Do(req, &ses)
if err != nil {
return nil, resp, err
}
return ses, resp, err
}
// GetMergeRequestStateEvent gets a single merge request state event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_state_events.html#get-single-merge-request-state-event
func (s *ResourceStateEventsService) GetMergeRequestStateEvent(pid interface{}, request int, event int, options ...RequestOptionFunc) (*StateEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_state_events/%d", pathEscape(project), request, event)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
se := new(StateEvent)
resp, err := s.client.Do(req, se)
if err != nil {
return nil, resp, err
}
return se, resp, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -98,7 +99,7 @@ type ListRunnersOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
func (s *RunnersService) ListRunners(opt *ListRunnersOptions, options ...RequestOptionFunc) ([]*Runner, *Response, error) {
req, err := s.client.NewRequest("GET", "runners", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "runners", opt, options)
if err != nil {
return nil, nil, err
}
@ -118,7 +119,7 @@ func (s *RunnersService) ListRunners(opt *ListRunnersOptions, options ...Request
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#list-all-runners
func (s *RunnersService) ListAllRunners(opt *ListRunnersOptions, options ...RequestOptionFunc) ([]*Runner, *Response, error) {
req, err := s.client.NewRequest("GET", "runners/all", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "runners/all", opt, options)
if err != nil {
return nil, nil, err
}
@ -143,7 +144,7 @@ func (s *RunnersService) GetRunnerDetails(rid interface{}, options ...RequestOpt
}
u := fmt.Sprintf("runners/%s", runner)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -182,7 +183,7 @@ func (s *RunnersService) UpdateRunnerDetails(rid interface{}, opt *UpdateRunnerD
}
u := fmt.Sprintf("runners/%s", runner)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -207,7 +208,7 @@ func (s *RunnersService) RemoveRunner(rid interface{}, options ...RequestOptionF
}
u := fmt.Sprintf("runners/%s", runner)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -238,7 +239,7 @@ func (s *RunnersService) ListRunnerJobs(rid interface{}, opt *ListRunnerJobsOpti
}
u := fmt.Sprintf("runners/%s/jobs", runner)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -270,7 +271,7 @@ func (s *RunnersService) ListProjectRunners(pid interface{}, opt *ListProjectRun
}
u := fmt.Sprintf("projects/%s/runners", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -304,7 +305,7 @@ func (s *RunnersService) EnableProjectRunner(pid interface{}, opt *EnableProject
}
u := fmt.Sprintf("projects/%s/runners", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -329,7 +330,7 @@ func (s *RunnersService) DisableProjectRunner(pid interface{}, runner int, optio
}
u := fmt.Sprintf("projects/%s/runners/%d", pathEscape(project), runner)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -361,7 +362,7 @@ func (s *RunnersService) ListGroupsRunners(gid interface{}, opt *ListGroupsRunne
}
u := fmt.Sprintf("groups/%s/runners", pathEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -409,7 +410,7 @@ type RegisterNewRunnerInfoOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#register-a-new-runner
func (s *RunnersService) RegisterNewRunner(opt *RegisterNewRunnerOptions, options ...RequestOptionFunc) (*Runner, *Response, error) {
req, err := s.client.NewRequest("POST", "runners", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "runners", opt, options)
if err != nil {
return nil, nil, err
}
@ -437,7 +438,7 @@ type DeleteRegisteredRunnerOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-authentication-token
func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("DELETE", "runners", opt, options)
req, err := s.client.NewRequest(http.MethodDelete, "runners", opt, options)
if err != nil {
return nil, err
}
@ -450,7 +451,7 @@ func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptio
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-id
func (s *RunnersService) DeleteRegisteredRunnerByID(rid int, options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("runners/%d", rid), nil, options)
req, err := s.client.NewRequest(http.MethodDelete, fmt.Sprintf("runners/%d", rid), nil, options)
if err != nil {
return nil, err
}
@ -472,7 +473,7 @@ type VerifyRegisteredRunnerOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#verify-authentication-for-a-registered-runner
func (s *RunnersService) VerifyRegisteredRunner(opt *VerifyRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("POST", "runners/verify", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "runners/verify", opt, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
)
// SearchService handles communication with the search related methods of the
@ -311,7 +312,7 @@ func (s *SearchService) UsersByProject(pid interface{}, query string, opt *Searc
func (s *SearchService) search(scope, query string, result interface{}, opt *SearchOptions, options ...RequestOptionFunc) (*Response, error) {
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
req, err := s.client.NewRequest("GET", "search", opts, options)
req, err := s.client.NewRequest(http.MethodGet, "search", opts, options)
if err != nil {
return nil, err
}
@ -328,7 +329,7 @@ func (s *SearchService) searchByGroup(gid interface{}, scope, query string, resu
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, err
}
@ -345,7 +346,7 @@ func (s *SearchService) searchByProject(pid interface{}, scope, query string, re
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
req, err := s.client.NewRequest("GET", u, opts, options)
req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"
)
@ -65,7 +66,7 @@ func (s *ServicesService) ListServices(pid interface{}, options ...RequestOption
}
u := fmt.Sprintf("projects/%s/services", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -109,7 +110,7 @@ func (s *ServicesService) GetDroneCIService(pid interface{}, options ...RequestO
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -145,7 +146,7 @@ func (s *ServicesService) SetDroneCIService(pid interface{}, opt *SetDroneCIServ
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -164,7 +165,7 @@ func (s *ServicesService) DeleteDroneCIService(pid interface{}, options ...Reque
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -200,7 +201,7 @@ func (s *ServicesService) GetExternalWikiService(pid interface{}, options ...Req
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -234,7 +235,7 @@ func (s *ServicesService) SetExternalWikiService(pid interface{}, opt *SetExtern
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -253,7 +254,7 @@ func (s *ServicesService) DeleteExternalWikiService(pid interface{}, options ...
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -290,7 +291,7 @@ func (s *ServicesService) GetGithubService(pid interface{}, options ...RequestOp
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -326,7 +327,7 @@ func (s *ServicesService) SetGithubService(pid interface{}, opt *SetGithubServic
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -345,7 +346,7 @@ func (s *ServicesService) DeleteGithubService(pid interface{}, options ...Reques
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -374,7 +375,7 @@ func (s *ServicesService) SetGitLabCIService(pid interface{}, opt *SetGitLabCISe
}
u := fmt.Sprintf("projects/%s/services/gitlab-ci", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -393,7 +394,7 @@ func (s *ServicesService) DeleteGitLabCIService(pid interface{}, options ...Requ
}
u := fmt.Sprintf("projects/%s/services/gitlab-ci", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -422,7 +423,7 @@ func (s *ServicesService) SetHipChatService(pid interface{}, opt *SetHipChatServ
}
u := fmt.Sprintf("projects/%s/services/hipchat", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -441,7 +442,7 @@ func (s *ServicesService) DeleteHipChatService(pid interface{}, options ...Reque
}
u := fmt.Sprintf("projects/%s/services/hipchat", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -479,7 +480,7 @@ func (s *ServicesService) GetJenkinsCIService(pid interface{}, options ...Reques
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -516,7 +517,7 @@ func (s *ServicesService) SetJenkinsCIService(pid interface{}, opt *SetJenkinsCI
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -535,7 +536,7 @@ func (s *ServicesService) DeleteJenkinsCIService(pid interface{}, options ...Req
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -606,7 +607,7 @@ func (s *ServicesService) GetJiraService(pid interface{}, options ...RequestOpti
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -649,7 +650,7 @@ func (s *ServicesService) SetJiraService(pid interface{}, opt *SetJiraServiceOpt
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -668,7 +669,7 @@ func (s *ServicesService) DeleteJiraService(pid interface{}, options ...RequestO
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -714,7 +715,7 @@ func (s *ServicesService) GetMicrosoftTeamsService(pid interface{}, options ...R
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -759,7 +760,7 @@ func (s *ServicesService) SetMicrosoftTeamsService(pid interface{}, opt *SetMicr
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -777,7 +778,7 @@ func (s *ServicesService) DeleteMicrosoftTeamsService(pid interface{}, options .
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -816,7 +817,7 @@ func (s *ServicesService) GetPipelinesEmailService(pid interface{}, options ...R
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -855,7 +856,7 @@ func (s *ServicesService) SetPipelinesEmailService(pid interface{}, opt *SetPipe
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -874,7 +875,7 @@ func (s *ServicesService) DeletePipelinesEmailService(pid interface{}, options .
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -925,7 +926,7 @@ func (s *ServicesService) GetSlackService(pid interface{}, options ...RequestOpt
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -987,7 +988,7 @@ func (s *ServicesService) SetSlackService(pid interface{}, opt *SetSlackServiceO
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -1006,7 +1007,7 @@ func (s *ServicesService) DeleteSlackService(pid interface{}, options ...Request
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -1044,7 +1045,7 @@ func (s *ServicesService) GetCustomIssueTrackerService(pid interface{}, options
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -1083,7 +1084,7 @@ func (s *ServicesService) SetCustomIssueTrackerService(pid interface{}, opt *Set
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
@ -1102,7 +1103,7 @@ func (s *ServicesService) DeleteCustomIssueTrackerService(pid interface{}, optio
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,7 +16,10 @@
package gitlab
import "time"
import (
"net/http"
"time"
)
// SettingsService handles communication with the application SettingsService
// related methods of the GitLab API.
@ -206,7 +209,7 @@ func (s Settings) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/settings.html#get-current-application.settings
func (s *SettingsService) GetSettings(options ...RequestOptionFunc) (*Settings, *Response, error) {
req, err := s.client.NewRequest("GET", "application/settings", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "application/settings", nil, options)
if err != nil {
return nil, nil, err
}
@ -394,7 +397,7 @@ type UpdateSettingsOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/settings.html#change-application.settings
func (s *SettingsService) UpdateSettings(opt *UpdateSettingsOptions, options ...RequestOptionFunc) (*Settings, *Response, error) {
req, err := s.client.NewRequest("PUT", "application/settings", opt, options)
req, err := s.client.NewRequest(http.MethodPut, "application/settings", opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2018, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,7 +16,10 @@
package gitlab
import "time"
import (
"net/http"
"time"
)
// SidekiqService handles communication with the sidekiq service
//
@ -42,7 +45,7 @@ type QueueMetrics struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-queue-metrics
func (s *SidekiqService) GetQueueMetrics(options ...RequestOptionFunc) (*QueueMetrics, *Response, error) {
req, err := s.client.NewRequest("GET", "/sidekiq/queue_metrics", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/queue_metrics", nil, options)
if err != nil {
return nil, nil, err
}
@ -79,7 +82,7 @@ type ProcessMetrics struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-process-metrics
func (s *SidekiqService) GetProcessMetrics(options ...RequestOptionFunc) (*ProcessMetrics, *Response, error) {
req, err := s.client.NewRequest("GET", "/sidekiq/process_metrics", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/process_metrics", nil, options)
if err != nil {
return nil, nil, err
}
@ -110,7 +113,7 @@ type JobStats struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-job-statistics
func (s *SidekiqService) GetJobStats(options ...RequestOptionFunc) (*JobStats, *Response, error) {
req, err := s.client.NewRequest("GET", "/sidekiq/job_stats", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/job_stats", nil, options)
if err != nil {
return nil, nil, err
}
@ -139,7 +142,7 @@ type CompoundMetrics struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-job-statistics
func (s *SidekiqService) GetCompoundMetrics(options ...RequestOptionFunc) (*CompoundMetrics, *Response, error) {
req, err := s.client.NewRequest("GET", "/sidekiq/compound_metrics", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/compound_metrics", nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"bytes"
"fmt"
"net/http"
"time"
)
@ -65,7 +66,7 @@ type ListSnippetsOptions ListOptions
//
// GitLab API docs: https://docs.gitlab.com/ce/api/snippets.html#list-snippets
func (s *SnippetsService) ListSnippets(opt *ListSnippetsOptions, options ...RequestOptionFunc) ([]*Snippet, *Response, error) {
req, err := s.client.NewRequest("GET", "snippets", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "snippets", opt, options)
if err != nil {
return nil, nil, err
}
@ -86,7 +87,7 @@ func (s *SnippetsService) ListSnippets(opt *ListSnippetsOptions, options ...Requ
func (s *SnippetsService) GetSnippet(snippet int, options ...RequestOptionFunc) (*Snippet, *Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -118,7 +119,7 @@ type CreateSnippetOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/snippets.html#create-new-snippet
func (s *SnippetsService) CreateSnippet(opt *CreateSnippetOptions, options ...RequestOptionFunc) (*Snippet, *Response, error) {
req, err := s.client.NewRequest("POST", "snippets", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "snippets", opt, options)
if err != nil {
return nil, nil, err
}
@ -152,7 +153,7 @@ type UpdateSnippetOptions struct {
func (s *SnippetsService) UpdateSnippet(snippet int, opt *UpdateSnippetOptions, options ...RequestOptionFunc) (*Snippet, *Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -175,7 +176,7 @@ func (s *SnippetsService) UpdateSnippet(snippet int, opt *UpdateSnippetOptions,
func (s *SnippetsService) DeleteSnippet(snippet int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -190,7 +191,7 @@ func (s *SnippetsService) DeleteSnippet(snippet int, options ...RequestOptionFun
func (s *SnippetsService) SnippetContent(snippet int, options ...RequestOptionFunc) ([]byte, *Response, error) {
u := fmt.Sprintf("snippets/%d/raw", snippet)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -215,7 +216,7 @@ type ExploreSnippetsOptions ListOptions
// GitLab API docs:
// https://docs.gitlab.com/ce/api/snippets.html#explore-all-public-snippets
func (s *SnippetsService) ExploreSnippets(opt *ExploreSnippetsOptions, options ...RequestOptionFunc) ([]*Snippet, *Response, error) {
req, err := s.client.NewRequest("GET", "snippets/public", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "snippets/public", nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"time"
)
@ -47,7 +48,7 @@ func (h Hook) String() string {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/system_hooks.html#list-system-hooks
func (s *SystemHooksService) ListHooks(options ...RequestOptionFunc) ([]*Hook, *Response, error) {
req, err := s.client.NewRequest("GET", "hooks", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "hooks", nil, options)
if err != nil {
return nil, nil, err
}
@ -80,7 +81,7 @@ type AddHookOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/system_hooks.html#add-new-system-hook-hook
func (s *SystemHooksService) AddHook(opt *AddHookOptions, options ...RequestOptionFunc) (*Hook, *Response, error) {
req, err := s.client.NewRequest("POST", "hooks", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "hooks", opt, options)
if err != nil {
return nil, nil, err
}
@ -117,7 +118,7 @@ func (h HookEvent) String() string {
func (s *SystemHooksService) TestHook(hook int, options ...RequestOptionFunc) (*HookEvent, *Response, error) {
u := fmt.Sprintf("hooks/%d", hook)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -140,7 +141,7 @@ func (s *SystemHooksService) TestHook(hook int, options ...RequestOptionFunc) (*
func (s *SystemHooksService) DeleteHook(hook int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("hooks/%d", hook)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -74,7 +75,7 @@ func (s *TagsService) ListTags(pid interface{}, opt *ListTagsOptions, options ..
}
u := fmt.Sprintf("projects/%s/repository/tags", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -100,7 +101,7 @@ func (s *TagsService) GetTag(pid interface{}, tag string, options ...RequestOpti
}
u := fmt.Sprintf("projects/%s/repository/tags/%s", pathEscape(project), url.PathEscape(tag))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -137,7 +138,7 @@ func (s *TagsService) CreateTag(pid interface{}, opt *CreateTagOptions, options
}
u := fmt.Sprintf("projects/%s/repository/tags", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -162,7 +163,7 @@ func (s *TagsService) DeleteTag(pid interface{}, tag string, options ...RequestO
}
u := fmt.Sprintf("projects/%s/repository/tags/%s", pathEscape(project), url.PathEscape(tag))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -194,7 +195,7 @@ func (s *TagsService) CreateReleaseNote(pid interface{}, tag string, opt *Create
}
u := fmt.Sprintf("projects/%s/repository/tags/%s/release", pathEscape(project), url.PathEscape(tag))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -229,7 +230,7 @@ func (s *TagsService) UpdateReleaseNote(pid interface{}, tag string, opt *Update
}
u := fmt.Sprintf("projects/%s/repository/tags/%s/release", pathEscape(project), url.PathEscape(tag))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,24 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"fmt"
"net/http"
)
// timeStatsService handles communication with the time tracking related
@ -44,7 +61,7 @@ func (s *timeStatsService) setTimeEstimate(pid interface{}, entity string, issue
}
u := fmt.Sprintf("projects/%s/%s/%d/time_estimate", pathEscape(project), entity, issue)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -68,7 +85,7 @@ func (s *timeStatsService) resetTimeEstimate(pid interface{}, entity string, iss
}
u := fmt.Sprintf("projects/%s/%s/%d/reset_time_estimate", pathEscape(project), entity, issue)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -99,7 +116,7 @@ func (s *timeStatsService) addSpentTime(pid interface{}, entity string, issue in
}
u := fmt.Sprintf("projects/%s/%s/%d/add_spent_time", pathEscape(project), entity, issue)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -123,7 +140,7 @@ func (s *timeStatsService) resetSpentTime(pid interface{}, entity string, issue
}
u := fmt.Sprintf("projects/%s/%s/%d/reset_spent_time", pathEscape(project), entity, issue)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -147,7 +164,7 @@ func (s *timeStatsService) getTimeSpent(pid interface{}, entity string, issue in
}
u := fmt.Sprintf("projects/%s/%s/%d/time_stats", pathEscape(project), entity, issue)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,7 +1,26 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import "time"
import "fmt"
import (
"fmt"
"net/http"
"time"
)
// TodosService handles communication with the todos related methods of
// the Gitlab API.
@ -135,7 +154,7 @@ type ListTodosOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/todos.html#get-a-list-of-todos
func (s *TodosService) ListTodos(opt *ListTodosOptions, options ...RequestOptionFunc) ([]*Todo, *Response, error) {
req, err := s.client.NewRequest("GET", "todos", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "todos", opt, options)
if err != nil {
return nil, nil, err
}
@ -155,7 +174,7 @@ func (s *TodosService) ListTodos(opt *ListTodosOptions, options ...RequestOption
func (s *TodosService) MarkTodoAsDone(id int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("todos/%d/mark_as_done", id)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
@ -167,7 +186,7 @@ func (s *TodosService) MarkTodoAsDone(id int, options ...RequestOptionFunc) (*Re
//
// GitLab API docs: https://docs.gitlab.com/ce/api/todos.html#mark-all-todos-as-done
func (s *TodosService) MarkAllTodosAsDone(options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("POST", "todos/mark_as_done", nil, options)
req, err := s.client.NewRequest(http.MethodPost, "todos/mark_as_done", nil, options)
if err != nil {
return nil, err
}

View file

@ -1,3 +1,19 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
@ -105,19 +121,28 @@ func DeploymentStatus(v DeploymentStatusValue) *DeploymentStatusValue {
return p
}
// FileAction represents the available actions that can be performed on a file.
// FileActionValue represents the available actions that can be performed on a file.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
type FileAction string
type FileActionValue string
// The available file actions.
const (
FileCreate FileAction = "create"
FileDelete FileAction = "delete"
FileMove FileAction = "move"
FileUpdate FileAction = "update"
FileCreate FileActionValue = "create"
FileDelete FileActionValue = "delete"
FileMove FileActionValue = "move"
FileUpdate FileActionValue = "update"
FileChmod FileActionValue = "chmod"
)
// FileAction is a helper routine that allocates a new FileActionValue value
// to store v and returns a pointer to it.
func FileAction(v FileActionValue) *FileActionValue {
p := new(FileActionValue)
*p = v
return p
}
// ISOTime represents an ISO 8601 formatted date
type ISOTime time.Time
@ -322,6 +347,27 @@ func VariableType(v VariableTypeValue) *VariableTypeValue {
return p
}
// WikiFormatValue represents the available wiki formats.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type WikiFormatValue string
// The available wiki formats.
const (
WikiFormatMarkdown WikiFormatValue = "markdown"
WikiFormatRDoc WikiFormatValue = "rdoc"
WikiFormatASCIIDoc WikiFormatValue = "asciidoc"
WikiFormatOrg WikiFormatValue = "org"
)
// WikiFormat is a helper routine that allocates a new WikiFormatValue
// to store v and returns a pointer to it.
func WikiFormat(v WikiFormatValue) *WikiFormatValue {
p := new(WikiFormatValue)
*p = v
return p
}
// MergeMethodValue represents a project merge type within GitLab.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#project-merge-method

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Sander van Harmelen
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package gitlab
import (
"errors"
"fmt"
"net/http"
"time"
)
@ -117,7 +118,10 @@ type ListUsersOptions struct {
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
TwoFactor *string `url:"two_factor,omitempty" json:"two_factor,omitempty"`
Admins *bool `url:"admins,omitempty" json:"admins,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
WithoutProjects *bool `url:"without_projects,omitempty" json:"without_projects,omitempty"`
WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
}
@ -125,7 +129,7 @@ type ListUsersOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-users
func (s *UsersService) ListUsers(opt *ListUsersOptions, options ...RequestOptionFunc) ([]*User, *Response, error) {
req, err := s.client.NewRequest("GET", "users", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "users", opt, options)
if err != nil {
return nil, nil, err
}
@ -145,7 +149,7 @@ func (s *UsersService) ListUsers(opt *ListUsersOptions, options ...RequestOption
func (s *UsersService) GetUser(user int, options ...RequestOptionFunc) (*User, *Response, error) {
u := fmt.Sprintf("users/%d", user)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -184,13 +188,14 @@ type CreateUserOptions struct {
SkipConfirmation *bool `url:"skip_confirmation,omitempty" json:"skip_confirmation,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
PrivateProfile *bool `url:"private_profile,omitempty" json:"private_profile,omitempty"`
Note *string `url:"note,omitempty" json:"note,omitempty"`
}
// CreateUser creates a new user. Note only administrators can create new users.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#user-creation
func (s *UsersService) CreateUser(opt *CreateUserOptions, options ...RequestOptionFunc) (*User, *Response, error) {
req, err := s.client.NewRequest("POST", "users", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "users", opt, options)
if err != nil {
return nil, nil, err
}
@ -227,6 +232,7 @@ type ModifyUserOptions struct {
SkipReconfirmation *bool `url:"skip_reconfirmation,omitempty" json:"skip_reconfirmation,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
PrivateProfile *bool `url:"private_profile,omitempty" json:"private_profile,omitempty"`
Note *string `url:"note,omitempty" json:"note,omitempty"`
}
// ModifyUser modifies an existing user. Only administrators can change attributes
@ -236,7 +242,7 @@ type ModifyUserOptions struct {
func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions, options ...RequestOptionFunc) (*User, *Response, error) {
u := fmt.Sprintf("users/%d", user)
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -260,7 +266,7 @@ func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions, options ...R
func (s *UsersService) DeleteUser(user int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d", user)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -272,7 +278,7 @@ func (s *UsersService) DeleteUser(user int, options ...RequestOptionFunc) (*Resp
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#current-user
func (s *UsersService) CurrentUser(options ...RequestOptionFunc) (*User, *Response, error) {
req, err := s.client.NewRequest("GET", "user", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "user", nil, options)
if err != nil {
return nil, nil, err
}
@ -300,7 +306,7 @@ type SSHKey struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-ssh-keys
func (s *UsersService) ListSSHKeys(options ...RequestOptionFunc) ([]*SSHKey, *Response, error) {
req, err := s.client.NewRequest("GET", "user/keys", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "user/keys", nil, options)
if err != nil {
return nil, nil, err
}
@ -328,7 +334,7 @@ type ListSSHKeysForUserOptions ListOptions
func (s *UsersService) ListSSHKeysForUser(user int, opt *ListSSHKeysForUserOptions, options ...RequestOptionFunc) ([]*SSHKey, *Response, error) {
u := fmt.Sprintf("users/%d/keys", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -348,7 +354,7 @@ func (s *UsersService) ListSSHKeysForUser(user int, opt *ListSSHKeysForUserOptio
func (s *UsersService) GetSSHKey(key int, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
u := fmt.Sprintf("user/keys/%d", key)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -375,7 +381,7 @@ type AddSSHKeyOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-ssh-key
func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
req, err := s.client.NewRequest("POST", "user/keys", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "user/keys", opt, options)
if err != nil {
return nil, nil, err
}
@ -396,7 +402,7 @@ func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions, options ...RequestOption
func (s *UsersService) AddSSHKeyForUser(user int, opt *AddSSHKeyOptions, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
u := fmt.Sprintf("users/%d/keys", user)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -419,7 +425,7 @@ func (s *UsersService) AddSSHKeyForUser(user int, opt *AddSSHKeyOptions, options
func (s *UsersService) DeleteSSHKey(key int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("user/keys/%d", key)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -435,7 +441,7 @@ func (s *UsersService) DeleteSSHKey(key int, options ...RequestOptionFunc) (*Res
func (s *UsersService) DeleteSSHKeyForUser(user, key int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/keys/%d", user, key)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -449,7 +455,7 @@ func (s *UsersService) DeleteSSHKeyForUser(user, key int, options ...RequestOpti
func (s *UsersService) BlockUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/block", user)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
@ -477,7 +483,7 @@ func (s *UsersService) BlockUser(user int, options ...RequestOptionFunc) error {
func (s *UsersService) UnblockUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/unblock", user)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
@ -505,7 +511,7 @@ func (s *UsersService) UnblockUser(user int, options ...RequestOptionFunc) error
func (s *UsersService) DeactivateUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/deactivate", user)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
@ -533,7 +539,7 @@ func (s *UsersService) DeactivateUser(user int, options ...RequestOptionFunc) er
func (s *UsersService) ActivateUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/activate", user)
req, err := s.client.NewRequest("POST", u, nil, options)
req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
@ -567,7 +573,7 @@ type Email struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-emails
func (s *UsersService) ListEmails(options ...RequestOptionFunc) ([]*Email, *Response, error) {
req, err := s.client.NewRequest("GET", "user/emails", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "user/emails", nil, options)
if err != nil {
return nil, nil, err
}
@ -595,7 +601,7 @@ type ListEmailsForUserOptions ListOptions
func (s *UsersService) ListEmailsForUser(user int, opt *ListEmailsForUserOptions, options ...RequestOptionFunc) ([]*Email, *Response, error) {
u := fmt.Sprintf("users/%d/emails", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -615,7 +621,7 @@ func (s *UsersService) ListEmailsForUser(user int, opt *ListEmailsForUserOptions
func (s *UsersService) GetEmail(email int, options ...RequestOptionFunc) (*Email, *Response, error) {
u := fmt.Sprintf("user/emails/%d", email)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -640,7 +646,7 @@ type AddEmailOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-email
func (s *UsersService) AddEmail(opt *AddEmailOptions, options ...RequestOptionFunc) (*Email, *Response, error) {
req, err := s.client.NewRequest("POST", "user/emails", opt, options)
req, err := s.client.NewRequest(http.MethodPost, "user/emails", opt, options)
if err != nil {
return nil, nil, err
}
@ -661,7 +667,7 @@ func (s *UsersService) AddEmail(opt *AddEmailOptions, options ...RequestOptionFu
func (s *UsersService) AddEmailForUser(user int, opt *AddEmailOptions, options ...RequestOptionFunc) (*Email, *Response, error) {
u := fmt.Sprintf("users/%d/emails", user)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -684,7 +690,7 @@ func (s *UsersService) AddEmailForUser(user int, opt *AddEmailOptions, options .
func (s *UsersService) DeleteEmail(email int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("user/emails/%d", email)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -700,7 +706,7 @@ func (s *UsersService) DeleteEmail(email int, options ...RequestOptionFunc) (*Re
func (s *UsersService) DeleteEmailForUser(user, email int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/emails/%d", user, email)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -740,7 +746,7 @@ type GetAllImpersonationTokensOptions struct {
func (s *UsersService) GetAllImpersonationTokens(user int, opt *GetAllImpersonationTokensOptions, options ...RequestOptionFunc) ([]*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -761,7 +767,7 @@ func (s *UsersService) GetAllImpersonationTokens(user int, opt *GetAllImpersonat
func (s *UsersService) GetImpersonationToken(user, token int, options ...RequestOptionFunc) (*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens/%d", user, token)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -793,7 +799,7 @@ type CreateImpersonationTokenOptions struct {
func (s *UsersService) CreateImpersonationToken(user int, opt *CreateImpersonationTokenOptions, options ...RequestOptionFunc) (*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens", user)
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -814,7 +820,7 @@ func (s *UsersService) CreateImpersonationToken(user int, opt *CreateImpersonati
func (s *UsersService) RevokeImpersonationToken(user, token int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens/%d", user, token)
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
@ -845,7 +851,7 @@ type GetUserActivitiesOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#get-user-activities-admin-only
func (s *UsersService) GetUserActivities(opt *GetUserActivitiesOptions, options ...RequestOptionFunc) ([]*UserActivity, *Response, error) {
req, err := s.client.NewRequest("GET", "user/activities", opt, options)
req, err := s.client.NewRequest(http.MethodGet, "user/activities", opt, options)
if err != nil {
return nil, nil, err
}
@ -874,7 +880,7 @@ type UserStatus struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#user-status
func (s *UsersService) CurrentUserStatus(options ...RequestOptionFunc) (*UserStatus, *Response, error) {
req, err := s.client.NewRequest("GET", "user/status", nil, options)
req, err := s.client.NewRequest(http.MethodGet, "user/status", nil, options)
if err != nil {
return nil, nil, err
}
@ -895,7 +901,7 @@ func (s *UsersService) CurrentUserStatus(options ...RequestOptionFunc) (*UserSta
func (s *UsersService) GetUserStatus(user int, options ...RequestOptionFunc) (*UserStatus, *Response, error) {
u := fmt.Sprintf("users/%d/status", user)
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
@ -923,7 +929,7 @@ type UserStatusOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#set-user-status
func (s *UsersService) SetUserStatus(opt *UserStatusOptions, options ...RequestOptionFunc) (*UserStatus, *Response, error) {
req, err := s.client.NewRequest("PUT", "user/status", opt, options)
req, err := s.client.NewRequest(http.MethodPut, "user/status", opt, options)
if err != nil {
return nil, nil, err
}
@ -964,7 +970,7 @@ type GetUserMembershipOptions struct {
func (s *UsersService) GetUserMemberships(user int, opt *GetUserMembershipOptions, options ...RequestOptionFunc) ([]*UserMembership, *Response, error) {
u := fmt.Sprintf("users/%d/memberships", user)
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,6 +1,25 @@
//
// Copyright 2021, Sander van Harmelen
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import "fmt"
import (
"fmt"
"net/http"
)
// ValidateService handles communication with the validation related methods of
// the GitLab API.
@ -38,7 +57,7 @@ func (s *ValidateService) Lint(content string, options ...RequestOptionFunc) (*L
}
opts.Content = content
req, err := s.client.NewRequest("POST", "ci/lint", &opts, options)
req, err := s.client.NewRequest(http.MethodPost, "ci/lint", &opts, options)
if err != nil {
return nil, nil, err
}
@ -72,7 +91,7 @@ func (s *ValidateService) ProjectNamespaceLint(pid interface{}, opt *ProjectName
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
req, err := s.client.NewRequest("POST", u, &opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, &opt, options)
if err != nil {
return nil, nil, err
}
@ -105,7 +124,7 @@ func (s *ValidateService) ProjectLint(pid interface{}, opt *ProjectLintOptions,
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
req, err := s.client.NewRequest("GET", u, &opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, &opt, options)
if err != nil {
return nil, nil, err
}

View file

@ -1,5 +1,5 @@
//
// Copyright 2017, Andrea Funto'
// Copyright 2021, Andrea Funto'
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package gitlab
import "net/http"
// VersionService handles communication with the GitLab server instance to
// retrieve its version information via the GitLab API.
//
@ -41,7 +43,7 @@ func (s Version) String() string {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/version.md
func (s *VersionService) GetVersion() (*Version, *Response, error) {
req, err := s.client.NewRequest("GET", "version", nil, nil)
req, err := s.client.NewRequest(http.MethodGet, "version", nil, nil)
if err != nil {
return nil, nil, err
}

View file

@ -1,4 +1,5 @@
// Copyright 2017, Stany MARCEL
//
// Copyright 2021, Stany MARCEL
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,6 +17,7 @@ package gitlab
import (
"fmt"
"net/http"
"net/url"
)
@ -27,26 +29,14 @@ type WikisService struct {
client *Client
}
// WikiFormat represents the available wiki formats.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type WikiFormat string
// The available wiki formats.
const (
WikiFormatMarkdown WikiFormat = "markdown"
WikiFormatRFoc WikiFormat = "rdoc"
WikiFormatASCIIDoc WikiFormat = "asciidoc"
)
// Wiki represents a GitLab wiki.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type Wiki struct {
Content string `json:"content"`
Format WikiFormat `json:"format"`
Slug string `json:"slug"`
Title string `json:"title"`
Content string `json:"content"`
Format WikiFormatValue `json:"format"`
Slug string `json:"slug"`
Title string `json:"title"`
}
func (w Wiki) String() string {
@ -73,18 +63,18 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options
}
u := fmt.Sprintf("projects/%s/wikis", pathEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
var w []*Wiki
resp, err := s.client.Do(req, &w)
var ws []*Wiki
resp, err := s.client.Do(req, &ws)
if err != nil {
return nil, resp, err
}
return w, resp, err
return ws, resp, err
}
// GetWikiPage gets a wiki page for a given project.
@ -98,13 +88,13 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Requ
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
var w *Wiki
resp, err := s.client.Do(req, &w)
w := new(Wiki)
resp, err := s.client.Do(req, w)
if err != nil {
return nil, resp, err
}
@ -117,9 +107,9 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Requ
// GitLab API docs:
// https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
type CreateWikiPageOptions struct {
Content *string `url:"content" json:"content"`
Title *string `url:"title" json:"title"`
Format *string `url:"format,omitempty" json:"format,omitempty"`
Content *string `url:"content,omitempty" json:"content,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// CreateWikiPage creates a new wiki page for the given repository with
@ -134,7 +124,7 @@ func (s *WikisService) CreateWikiPage(pid interface{}, opt *CreateWikiPageOption
}
u := fmt.Sprintf("projects/%s/wikis", pathEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options)
req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -153,9 +143,9 @@ func (s *WikisService) CreateWikiPage(pid interface{}, opt *CreateWikiPageOption
// GitLab API docs:
// https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
type EditWikiPageOptions struct {
Content *string `url:"content" json:"content"`
Title *string `url:"title" json:"title"`
Format *string `url:"format,omitempty" json:"format,omitempty"`
Content *string `url:"content,omitempty" json:"content,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// EditWikiPage Updates an existing wiki page. At least one parameter is
@ -170,7 +160,7 @@ func (s *WikisService) EditWikiPage(pid interface{}, slug string, opt *EditWikiP
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
req, err := s.client.NewRequest("PUT", u, opt, options)
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
@ -195,7 +185,7 @@ func (s *WikisService) DeleteWikiPage(pid interface{}, slug string, options ...R
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
req, err := s.client.NewRequest("DELETE", u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}