Commit d1c986c3 authored by Sander van Harmelen's avatar Sander van Harmelen

All 8.17 related V4 API changes (#161)

* Change `IID` to `IIDs` where applicable

* Remove the `/project/search` endpoint

Instead `/project?search=query` should be used to search a project. This endpoint already exists as the `ListProjects` function already contains a `search` option.

* Do not return deprecated field `expired_at`

* Change `keys` to `deploy_keys`

And add all missing `deploy_keys` endpoints.
parent 9dc6e9ee
...@@ -25,8 +25,7 @@ import ( ...@@ -25,8 +25,7 @@ import (
// DeployKeysService handles communication with the keys related methods // DeployKeysService handles communication with the keys related methods
// of the GitLab API. // of the GitLab API.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/deploy_keys.html
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md
type DeployKeysService struct { type DeployKeysService struct {
client *Client client *Client
} }
...@@ -44,41 +43,60 @@ func (k DeployKey) String() string { ...@@ -44,41 +43,60 @@ func (k DeployKey) String() string {
return Stringify(k) return Stringify(k)
} }
// ListDeployKeys gets a list of a project's deploy keys // ListAllDeployKeys gets a list of all deploy keys
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md#list-deploy-keys // https://docs.gitlab.com/ce/api/deploy_keys.html#list-all-deploy-keys
func (s *DeployKeysService) ListDeployKeys(pid interface{}, options ...OptionFunc) ([]*DeployKey, *Response, error) { func (s *DeployKeysService) ListAllDeployKeys(options ...OptionFunc) ([]*DeployKey, *Response, error) {
req, err := s.client.NewRequest("GET", "deploy_keys", nil, options)
if err != nil {
return nil, nil, err
}
var ks []*DeployKey
resp, err := s.client.Do(req, &ks)
if err != nil {
return nil, resp, err
}
return ks, resp, err
}
// ListProjectDeployKeys gets a list of a project's deploy keys
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_keys.html#list-project-deploy-keys
func (s *DeployKeysService) ListProjectDeployKeys(pid interface{}, options ...OptionFunc) ([]*DeployKey, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/keys", url.QueryEscape(project)) u := fmt.Sprintf("projects/%s/deploy_keys", url.QueryEscape(project))
req, err := s.client.NewRequest("GET", u, nil, options) req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
var k []*DeployKey var ks []*DeployKey
resp, err := s.client.Do(req, &k) resp, err := s.client.Do(req, &ks)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return k, resp, err return ks, resp, err
} }
// GetDeployKey gets a single deploy key. // GetDeployKey gets a single deploy key.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md#single-deploy-key // https://docs.gitlab.com/ce/api/deploy_keys.html#single-deploy-key
func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*DeployKey, *Response, error) { func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*DeployKey, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/keys/%d", url.QueryEscape(project), deployKey) u := fmt.Sprintf("projects/%s/deploy_keys/%d", url.QueryEscape(project), deployKey)
req, err := s.client.NewRequest("GET", u, nil, options) req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil { if err != nil {
...@@ -97,7 +115,7 @@ func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options ...@@ -97,7 +115,7 @@ func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options
// AddDeployKeyOptions represents the available ADDDeployKey() options. // AddDeployKeyOptions represents the available ADDDeployKey() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md#add-deploy-key // https://docs.gitlab.com/ce/api/deploy_keys.html#add-deploy-key
type AddDeployKeyOptions struct { type AddDeployKeyOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"` Title *string `url:"title,omitempty" json:"title,omitempty"`
Key *string `url:"key,omitempty" json:"key,omitempty"` Key *string `url:"key,omitempty" json:"key,omitempty"`
...@@ -109,13 +127,13 @@ type AddDeployKeyOptions struct { ...@@ -109,13 +127,13 @@ type AddDeployKeyOptions struct {
// original one was is accessible by same user. // original one was is accessible by same user.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md#add-deploy-key // https://docs.gitlab.com/ce/api/deploy_keys.html#add-deploy-key
func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptions, options ...OptionFunc) (*DeployKey, *Response, error) { func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptions, options ...OptionFunc) (*DeployKey, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/keys", url.QueryEscape(project)) u := fmt.Sprintf("projects/%s/deploy_keys", url.QueryEscape(project))
req, err := s.client.NewRequest("POST", u, opt, options) req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil { if err != nil {
...@@ -134,13 +152,13 @@ func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptio ...@@ -134,13 +152,13 @@ func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptio
// DeleteDeployKey deletes a deploy key from a project. // DeleteDeployKey deletes a deploy key from a project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/deploy_keys.md#delete-deploy-key // https://docs.gitlab.com/ce/api/deploy_keys.html#delete-deploy-key
func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*Response, error) { func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
u := fmt.Sprintf("projects/%s/keys/%d", url.QueryEscape(project), deployKey) u := fmt.Sprintf("projects/%s/deploy_keys/%d", url.QueryEscape(project), deployKey)
req, err := s.client.NewRequest("DELETE", u, nil, options) req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil { if err != nil {
...@@ -149,3 +167,28 @@ func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, opti ...@@ -149,3 +167,28 @@ func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, opti
return s.client.Do(req, nil) return s.client.Do(req, nil)
} }
// EnableDeployKey enables a deploy key.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_keys.html#enable-deploy-key
func (s *DeployKeysService) EnableDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*DeployKey, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d/enable", url.QueryEscape(project), deployKey)
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, nil, err
}
k := new(DeployKey)
resp, err := s.client.Do(req, k)
if err != nil {
return nil, resp, err
}
return k, resp, err
}
...@@ -27,16 +27,14 @@ import ( ...@@ -27,16 +27,14 @@ import (
// IssuesService handles communication with the issue related methods // IssuesService handles communication with the issue related methods
// of the GitLab API. // of the GitLab API.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md
type IssuesService struct { type IssuesService struct {
client *Client client *Client
} }
// Issue represents a GitLab issue. // Issue represents a GitLab issue.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md
type Issue struct { type Issue struct {
ID int `json:"id"` ID int `json:"id"`
IID int `json:"iid"` IID int `json:"iid"`
...@@ -85,12 +83,13 @@ func (l *Labels) MarshalJSON() ([]byte, error) { ...@@ -85,12 +83,13 @@ func (l *Labels) MarshalJSON() ([]byte, error) {
// ListIssuesOptions represents the available ListIssues() options. // ListIssuesOptions represents the available ListIssues() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#list-issues
type ListIssuesOptions struct { type ListIssuesOptions struct {
ListOptions ListOptions
IIDs []int `url:"iids[],omitempty" json:"iids,omitempty"`
State *string `url:"state,omitempty" json:"state,omitempty"` State *string `url:"state,omitempty" json:"state,omitempty"`
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"` Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"` OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"` Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
} }
...@@ -98,8 +97,7 @@ type ListIssuesOptions struct { ...@@ -98,8 +97,7 @@ type ListIssuesOptions struct {
// ListIssues gets all issues created by authenticated user. This function // ListIssues gets all issues created by authenticated user. This function
// takes pagination parameters page and per_page to restrict the list of issues. // takes pagination parameters page and per_page to restrict the list of issues.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#list-issues
func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) { func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) {
req, err := s.client.NewRequest("GET", "issues", opt, options) req, err := s.client.NewRequest("GET", "issues", opt, options)
if err != nil { if err != nil {
...@@ -115,13 +113,50 @@ func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...OptionFunc ...@@ -115,13 +113,50 @@ func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...OptionFunc
return i, resp, err return i, resp, err
} }
// ListGroupIssuesOptions represents the available ListGroupIssues() options.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-group-issues
type ListGroupIssuesOptions struct {
ListOptions
IIDs []int `url:"iids[],omitempty" json:"iids,omitempty"`
State *string `url:"state,omitempty" json:"state,omitempty"`
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
}
// ListGroupIssues gets a list of group issues. This function accepts
// pagination parameters page and per_page to return the list of group issues.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-group-issues
func (s *IssuesService) ListGroupIssues(pid interface{}, opt *ListGroupIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) {
group, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("group/%s/issues", url.QueryEscape(group))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
return nil, nil, err
}
var i []*Issue
resp, err := s.client.Do(req, &i)
if err != nil {
return nil, resp, err
}
return i, resp, err
}
// ListProjectIssuesOptions represents the available ListProjectIssues() options. // ListProjectIssuesOptions represents the available ListProjectIssues() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-project-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#list-issues
type ListProjectIssuesOptions struct { type ListProjectIssuesOptions struct {
ListOptions ListOptions
IID *int `url:"iid,omitempty" json:"iid,omitempty"` IIDs []int `url:"iids[],omitempty" json:"iids,omitempty"`
State *string `url:"state,omitempty" json:"state,omitempty"` State *string `url:"state,omitempty" json:"state,omitempty"`
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"` Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"`
...@@ -132,8 +167,7 @@ type ListProjectIssuesOptions struct { ...@@ -132,8 +167,7 @@ type ListProjectIssuesOptions struct {
// ListProjectIssues gets a list of project issues. This function accepts // ListProjectIssues gets a list of project issues. This function accepts
// pagination parameters page and per_page to return the list of project issues. // pagination parameters page and per_page to return the list of project issues.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-project-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#list-project-issues
func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) { func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -157,8 +191,7 @@ func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssue ...@@ -157,8 +191,7 @@ func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssue
// GetIssue gets a single project issue. // GetIssue gets a single project issue.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#single-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#single-issues
func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...OptionFunc) (*Issue, *Response, error) { func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...OptionFunc) (*Issue, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -182,8 +215,7 @@ func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...OptionFu ...@@ -182,8 +215,7 @@ func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...OptionFu
// CreateIssueOptions represents the available CreateIssue() options. // CreateIssueOptions represents the available CreateIssue() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#new-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#new-issues
type CreateIssueOptions struct { type CreateIssueOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"` Title *string `url:"title,omitempty" json:"title,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"`
...@@ -194,8 +226,7 @@ type CreateIssueOptions struct { ...@@ -194,8 +226,7 @@ type CreateIssueOptions struct {
// CreateIssue creates a new project issue. // CreateIssue creates a new project issue.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#new-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#new-issues
func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) { func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -219,8 +250,7 @@ func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, op ...@@ -219,8 +250,7 @@ func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, op
// UpdateIssueOptions represents the available UpdateIssue() options. // UpdateIssueOptions represents the available UpdateIssue() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#edit-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#edit-issues
type UpdateIssueOptions struct { type UpdateIssueOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"` Title *string `url:"title,omitempty" json:"title,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"`
...@@ -233,8 +263,7 @@ type UpdateIssueOptions struct { ...@@ -233,8 +263,7 @@ type UpdateIssueOptions struct {
// UpdateIssue updates an existing project issue. This function is also used // UpdateIssue updates an existing project issue. This function is also used
// to mark an issue as closed. // to mark an issue as closed.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#edit-issues
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#edit-issues
func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) { func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -258,8 +287,7 @@ func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssue ...@@ -258,8 +287,7 @@ func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssue
// DeleteIssue deletes a single project issue. // DeleteIssue deletes a single project issue.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#delete-an-issue
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/issues.md#delete-an-issue
func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...OptionFunc) (*Response, error) { func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
......
...@@ -108,7 +108,7 @@ func (m MergeRequest) String() string { ...@@ -108,7 +108,7 @@ func (m MergeRequest) String() string {
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/merge_requests.md#list-merge-requests // https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/merge_requests.md#list-merge-requests
type ListMergeRequestsOptions struct { type ListMergeRequestsOptions struct {
ListOptions ListOptions
IID *int `url:"iid,omitempty" json:"iid,omitempty"` IIDs []int `url:"iids[],omitempty" json:"iids,omitempty"`
State *string `url:"state,omitempty" json:"state,omitempty"` State *string `url:"state,omitempty" json:"state,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"` OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"` Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
......
...@@ -48,7 +48,6 @@ type Snippet struct { ...@@ -48,7 +48,6 @@ type Snippet struct {
State string `json:"state"` State string `json:"state"`
CreatedAt *time.Time `json:"created_at"` CreatedAt *time.Time `json:"created_at"`
} `json:"author"` } `json:"author"`
ExpiresAt *time.Time `json:"expires_at"`
UpdatedAt *time.Time `json:"updated_at"` UpdatedAt *time.Time `json:"updated_at"`
CreatedAt *time.Time `json:"created_at"` CreatedAt *time.Time `json:"created_at"`
} }
......
...@@ -25,16 +25,14 @@ import ( ...@@ -25,16 +25,14 @@ import (
// ProjectsService handles communication with the repositories related methods // ProjectsService handles communication with the repositories related methods
// of the GitLab API. // of the GitLab API.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md
type ProjectsService struct { type ProjectsService struct {
client *Client client *Client
} }
// Project represents a GitLab project. // Project represents a GitLab project.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md
type Project struct { type Project struct {
ID int `json:"id"` ID int `json:"id"`
Description string `json:"description"` Description string `json:"description"`
...@@ -74,7 +72,6 @@ type Project struct { ...@@ -74,7 +72,6 @@ type Project struct {
OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"` OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
LFSEnabled bool `json:"lfs_enabled"` LFSEnabled bool `json:"lfs_enabled"`
RequestAccessEnabled bool `json:"request_access_enabled"` RequestAccessEnabled bool `json:"request_access_enabled"`
ForkedFromProject *ForkParent `json:"forked_from_project"`
SharedWithGroups []struct { SharedWithGroups []struct {
GroupID int `json:"group_id"` GroupID int `json:"group_id"`
GroupName string `json:"group_name"` GroupName string `json:"group_name"`
...@@ -144,25 +141,13 @@ type GroupAccess struct { ...@@ -144,25 +141,13 @@ type GroupAccess struct {
NotificationLevel NotificationLevelValue `json:"notification_level"` NotificationLevel NotificationLevelValue `json:"notification_level"`
} }
// ForkParent represents the parent project when this is a fork.
type ForkParent struct {
HTTPURLToRepo string `json:"http_url_to_repo"`
ID int `json:"id"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
WebURL string `json:"web_url"`
}
func (s Project) String() string { func (s Project) String() string {
return Stringify(s) return Stringify(s)
} }
// ListProjectsOptions represents the available ListProjects() options. // ListProjectsOptions represents the available ListProjects() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-projects
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-projects
type ListProjectsOptions struct { type ListProjectsOptions struct {
ListOptions ListOptions
Archived *bool `url:"archived,omitempty" json:"archived,omitempty"` Archived *bool `url:"archived,omitempty" json:"archived,omitempty"`
...@@ -174,10 +159,9 @@ type ListProjectsOptions struct { ...@@ -174,10 +159,9 @@ type ListProjectsOptions struct {
Statistics *bool `url:"statistics,omitempty" json:"statistics,omitempty"` Statistics *bool `url:"statistics,omitempty" json:"statistics,omitempty"`
} }
// ListProjects gets a list of projects for which the authenticated user is a member // ListProjects gets a list of projects accessible by the authenticated user.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-projects
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-projects
func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects", opt, options) req, err := s.client.NewRequest("GET", "projects", opt, options)
if err != nil { if err != nil {
...@@ -193,30 +177,11 @@ func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...Opti ...@@ -193,30 +177,11 @@ func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...Opti
return p, resp, err return p, resp, err
} }
// ListVisibleProjects gets a list of projects accessible by the authenticated user.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-projects
func (s *ProjectsService) ListVisibleProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects/visible", opt, options)
if err != nil {
return nil, nil, err
}
var p []*Project
resp, err := s.client.Do(req, &p)
if err != nil {
return nil, resp, err
}
return p, resp, err
}
// ListOwnedProjects gets a list of projects which are owned by the // ListOwnedProjects gets a list of projects which are owned by the
// authenticated user. // authenticated user.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-owned-projects // https://docs.gitlab.com/ce/api/projects.html#list-owned-projects
func (s *ProjectsService) ListOwnedProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { func (s *ProjectsService) ListOwnedProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects/owned", opt, options) req, err := s.client.NewRequest("GET", "projects/owned", opt, options)
if err != nil { if err != nil {
...@@ -236,7 +201,7 @@ func (s *ProjectsService) ListOwnedProjects(opt *ListProjectsOptions, options .. ...@@ -236,7 +201,7 @@ func (s *ProjectsService) ListOwnedProjects(opt *ListProjectsOptions, options ..
// authenticated user. // authenticated user.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-starred-projects // https://docs.gitlab.com/ce/api/projects.html#list-starred-projects
func (s *ProjectsService) ListStarredProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { func (s *ProjectsService) ListStarredProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects/starred", opt, options) req, err := s.client.NewRequest("GET", "projects/starred", opt, options)
if err != nil { if err != nil {
...@@ -255,7 +220,7 @@ func (s *ProjectsService) ListStarredProjects(opt *ListProjectsOptions, options ...@@ -255,7 +220,7 @@ func (s *ProjectsService) ListStarredProjects(opt *ListProjectsOptions, options
// ListAllProjects gets a list of all GitLab projects (admin only). // ListAllProjects gets a list of all GitLab projects (admin only).
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-all-projects // https://docs.gitlab.com/ce/api/projects.html#list-all-projects
func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects/all", opt, options) req, err := s.client.NewRequest("GET", "projects/all", opt, options)
if err != nil { if err != nil {
...@@ -275,7 +240,7 @@ func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions, options ...O ...@@ -275,7 +240,7 @@ func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions, options ...O
// NAMESPACE/PROJECT_NAME, which is owned by the authenticated user. // NAMESPACE/PROJECT_NAME, which is owned by the authenticated user.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-single-project // https://docs.gitlab.com/ce/api/projects.html#get-single-project
func (s *ProjectsService) GetProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) GetProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -297,42 +262,10 @@ func (s *ProjectsService) GetProject(pid interface{}, options ...OptionFunc) (*P ...@@ -297,42 +262,10 @@ func (s *ProjectsService) GetProject(pid interface{}, options ...OptionFunc) (*P
return p, resp, err return p, resp, err
} }
// SearchProjectsOptions represents the available SearchProjects() options.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#search-for-projects-by-name
type SearchProjectsOptions struct {
ListOptions
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
}
// SearchProjects searches for projects by name which are accessible to the
// authenticated user.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#search-for-projects-by-name
func (s *ProjectsService) SearchProjects(query string, opt *SearchProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
u := fmt.Sprintf("projects/search/%s", query)
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
return nil, nil, err
}
var p []*Project
resp, err := s.client.Do(req, &p)
if err != nil {
return nil, resp, err
}
return p, resp, err
}
// ProjectEvent represents a GitLab project event. // ProjectEvent represents a GitLab project event.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-project-events // https://docs.gitlab.com/ce/api/projects.html#get-project-events
type ProjectEvent struct { type ProjectEvent struct {
Title interface{} `json:"title"` Title interface{} `json:"title"`
ProjectID int `json:"project_id"` ProjectID int `json:"project_id"`
...@@ -361,7 +294,7 @@ func (s ProjectEvent) String() string { ...@@ -361,7 +294,7 @@ func (s ProjectEvent) String() string {
// GetProjectEventsOptions represents the available GetProjectEvents() options. // GetProjectEventsOptions represents the available GetProjectEvents() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-project-events // https://docs.gitlab.com/ce/api/projects.html#get-project-events
type GetProjectEventsOptions struct { type GetProjectEventsOptions struct {
ListOptions ListOptions
} }
...@@ -370,7 +303,7 @@ type GetProjectEventsOptions struct { ...@@ -370,7 +303,7 @@ type GetProjectEventsOptions struct {
// newest to latest. // newest to latest.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-project-events // https://docs.gitlab.com/ce/api/projects.html#get-project-events
func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEventsOptions, options ...OptionFunc) ([]*ProjectEvent, *Response, error) { func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEventsOptions, options ...OptionFunc) ([]*ProjectEvent, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -394,12 +327,10 @@ func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEvent ...@@ -394,12 +327,10 @@ func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEvent
// CreateProjectOptions represents the available CreateProjects() options. // CreateProjectOptions represents the available CreateProjects() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#create-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#create-project
type CreateProjectOptions struct { type CreateProjectOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"` Path *string `url:"path,omitempty" json:"path,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"` // note: this does not work
NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"` NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"`
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"` IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
...@@ -414,15 +345,13 @@ type CreateProjectOptions struct { ...@@ -414,15 +345,13 @@ type CreateProjectOptions struct {
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"` ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"` PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
OnlyAllowMergeIfBuildSucceeds *bool `url:"only_allow_merge_if_build_succeeds,omitempty" json:"only_allow_merge_if_build_succeeds,omitempty"` OnlyAllowMergeIfBuildSucceeds *bool `url:"only_allow_merge_if_build_succeeds,omitempty" json:"only_allow_merge_if_build_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"` LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"` RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
} }
// CreateProject creates a new project owned by the authenticated user. // CreateProject creates a new project owned by the authenticated user.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#create-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#create-project
func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...OptionFunc) (*Project, *Response, error) {
req, err := s.client.NewRequest("POST", "projects", opt, options) req, err := s.client.NewRequest("POST", "projects", opt, options)
if err != nil { if err != nil {
...@@ -439,18 +368,28 @@ func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...Op ...@@ -439,18 +368,28 @@ func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...Op
} }
// CreateProjectForUserOptions represents the available CreateProjectForUser() // CreateProjectForUserOptions represents the available CreateProjectForUser()
// options; these are identical to those for an ordinary Project, since the // options.
// required "user_id" parameter is provided in the request URL.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#create-project-for-user // https://docs.gitlab.com/ce/api/projects.html#create-project-for-user
type CreateProjectForUserOptions CreateProjectOptions type CreateProjectForUserOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
MergeRequestsEnabled *bool `url:"merge_requests_enabled,omitempty" json:"merge_requests_enabled,omitempty"`
WikiEnabled *bool `url:"wiki_enabled,omitempty" json:"wiki_enabled,omitempty"`
SnippetsEnabled *bool `url:"snippets_enabled,omitempty" json:"snippets_enabled,omitempty"`
Public *bool `url:"public,omitempty" json:"public,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility_level,omitempty" json:"visibility_level,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
}
// CreateProjectForUser creates a new project owned by the specified user. // CreateProjectForUser creates a new project owned by the specified user.
// Available only for admins. // Available only for admins.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#create-project-for-user // https://docs.gitlab.com/ce/api/projects.html#create-project-for-user
func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUserOptions, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUserOptions, options ...OptionFunc) (*Project, *Response, error) {
u := fmt.Sprintf("projects/user/%d", user) u := fmt.Sprintf("projects/user/%d", user)
...@@ -470,8 +409,7 @@ func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUs ...@@ -470,8 +409,7 @@ func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUs
// EditProjectOptions represents the available EditProject() options. // EditProjectOptions represents the available EditProject() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project
type EditProjectOptions struct { type EditProjectOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"` Path *string `url:"path,omitempty" json:"path,omitempty"`
...@@ -497,8 +435,7 @@ type EditProjectOptions struct { ...@@ -497,8 +435,7 @@ type EditProjectOptions struct {
// EditProject updates an existing project. // EditProject updates an existing project.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project
func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, options ...OptionFunc) (*Project, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -523,8 +460,7 @@ func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, ...@@ -523,8 +460,7 @@ func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions,
// ForkProject forks a project into the user namespace of the authenticated // ForkProject forks a project into the user namespace of the authenticated
// user. // user.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#fork-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#fork-project
func (s *ProjectsService) ForkProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) ForkProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -549,8 +485,7 @@ func (s *ProjectsService) ForkProject(pid interface{}, options ...OptionFunc) (* ...@@ -549,8 +485,7 @@ func (s *ProjectsService) ForkProject(pid interface{}, options ...OptionFunc) (*
// DeleteProject removes a project including all associated resources // DeleteProject removes a project including all associated resources
// (issues, merge requests etc.) // (issues, merge requests etc.)
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#remove-project
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#remove-project
func (s *ProjectsService) DeleteProject(pid interface{}, options ...OptionFunc) (*Response, error) { func (s *ProjectsService) DeleteProject(pid interface{}, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -569,7 +504,7 @@ func (s *ProjectsService) DeleteProject(pid interface{}, options ...OptionFunc) ...@@ -569,7 +504,7 @@ func (s *ProjectsService) DeleteProject(pid interface{}, options ...OptionFunc)
// ProjectMember represents a project member. // ProjectMember represents a project member.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-team-members // https://docs.gitlab.com/ce/api/projects.html#list-project-team-members
type ProjectMember struct { type ProjectMember struct {
ID int `json:"id"` ID int `json:"id"`
Username string `json:"username"` Username string `json:"username"`
...@@ -584,7 +519,7 @@ type ProjectMember struct { ...@@ -584,7 +519,7 @@ type ProjectMember struct {
// options. // options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-team-members // https://docs.gitlab.com/ce/api/projects.html#list-project-team-members
type ListProjectMembersOptions struct { type ListProjectMembersOptions struct {
ListOptions ListOptions
Query *string `url:"query,omitempty" json:"query,omitempty"` Query *string `url:"query,omitempty" json:"query,omitempty"`
...@@ -593,7 +528,7 @@ type ListProjectMembersOptions struct { ...@@ -593,7 +528,7 @@ type ListProjectMembersOptions struct {
// ListProjectMembers gets a list of a project's team members. // ListProjectMembers gets a list of a project's team members.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-team-members // https://docs.gitlab.com/ce/api/projects.html#list-project-team-members
func (s *ProjectsService) ListProjectMembers(pid interface{}, opt *ListProjectMembersOptions, options ...OptionFunc) ([]*ProjectMember, *Response, error) { func (s *ProjectsService) ListProjectMembers(pid interface{}, opt *ListProjectMembersOptions, options ...OptionFunc) ([]*ProjectMember, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -618,7 +553,7 @@ func (s *ProjectsService) ListProjectMembers(pid interface{}, opt *ListProjectMe ...@@ -618,7 +553,7 @@ func (s *ProjectsService) ListProjectMembers(pid interface{}, opt *ListProjectMe
// GetProjectMember gets a project team member. // GetProjectMember gets a project team member.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-project-team-member // https://docs.gitlab.com/ce/api/projects.html#get-project-team-member
func (s *ProjectsService) GetProjectMember(pid interface{}, user int, options ...OptionFunc) (*ProjectMember, *Response, error) { func (s *ProjectsService) GetProjectMember(pid interface{}, user int, options ...OptionFunc) (*ProjectMember, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -643,7 +578,7 @@ func (s *ProjectsService) GetProjectMember(pid interface{}, user int, options .. ...@@ -643,7 +578,7 @@ func (s *ProjectsService) GetProjectMember(pid interface{}, user int, options ..
// AddProjectMemberOptions represents the available AddProjectMember() options. // AddProjectMemberOptions represents the available AddProjectMember() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#add-project-team-member // https://docs.gitlab.com/ce/api/projects.html#add-project-team-member
type AddProjectMemberOptions struct { type AddProjectMemberOptions struct {
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"` UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"` AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
...@@ -655,7 +590,7 @@ type AddProjectMemberOptions struct { ...@@ -655,7 +590,7 @@ type AddProjectMemberOptions struct {
// existing membership. // existing membership.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#add-project-team-member // https://docs.gitlab.com/ce/api/projects.html#add-project-team-member
func (s *ProjectsService) AddProjectMember(pid interface{}, opt *AddProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) { func (s *ProjectsService) AddProjectMember(pid interface{}, opt *AddProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -680,7 +615,7 @@ func (s *ProjectsService) AddProjectMember(pid interface{}, opt *AddProjectMembe ...@@ -680,7 +615,7 @@ func (s *ProjectsService) AddProjectMember(pid interface{}, opt *AddProjectMembe
// EditProjectMemberOptions represents the available EditProjectMember() options. // EditProjectMemberOptions represents the available EditProjectMember() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project-team-member // https://docs.gitlab.com/ce/api/projects.html#edit-project-team-member
type EditProjectMemberOptions struct { type EditProjectMemberOptions struct {
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"` AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
} }
...@@ -688,7 +623,7 @@ type EditProjectMemberOptions struct { ...@@ -688,7 +623,7 @@ type EditProjectMemberOptions struct {
// EditProjectMember updates a project team member to a specified access level.. // EditProjectMember updates a project team member to a specified access level..
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project-team-member // https://docs.gitlab.com/ce/api/projects.html#edit-project-team-member
func (s *ProjectsService) EditProjectMember(pid interface{}, user int, opt *EditProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) { func (s *ProjectsService) EditProjectMember(pid interface{}, user int, opt *EditProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -713,7 +648,7 @@ func (s *ProjectsService) EditProjectMember(pid interface{}, user int, opt *Edit ...@@ -713,7 +648,7 @@ func (s *ProjectsService) EditProjectMember(pid interface{}, user int, opt *Edit
// DeleteProjectMember removes a user from a project team. // DeleteProjectMember removes a user from a project team.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#remove-project-team-member // https://docs.gitlab.com/ce/api/projects.html#remove-project-team-member
func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int, options ...OptionFunc) (*Response, error) { func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -732,7 +667,7 @@ func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int, options ...@@ -732,7 +667,7 @@ func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int, options
// ProjectHook represents a project hook. // ProjectHook represents a project hook.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-hooks // https://docs.gitlab.com/ce/api/projects.html#list-project-hooks
type ProjectHook struct { type ProjectHook struct {
ID int `json:"id"` ID int `json:"id"`
URL string `json:"url"` URL string `json:"url"`
...@@ -751,8 +686,7 @@ type ProjectHook struct { ...@@ -751,8 +686,7 @@ type ProjectHook struct {
// ListProjectHooksOptions represents the available ListProjectHooks() options. // ListProjectHooksOptions represents the available ListProjectHooks() options.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-project-hooks
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-hooks
type ListProjectHooksOptions struct { type ListProjectHooksOptions struct {
ListOptions ListOptions
} }
...@@ -760,7 +694,7 @@ type ListProjectHooksOptions struct { ...@@ -760,7 +694,7 @@ type ListProjectHooksOptions struct {
// ListProjectHooks gets a list of project hooks. // ListProjectHooks gets a list of project hooks.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#list-project-hooks // https://docs.gitlab.com/ce/api/projects.html#list-project-hooks
func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHooksOptions, options ...OptionFunc) ([]*ProjectHook, *Response, error) { func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHooksOptions, options ...OptionFunc) ([]*ProjectHook, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -785,7 +719,7 @@ func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHook ...@@ -785,7 +719,7 @@ func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHook
// GetProjectHook gets a specific hook for a project. // GetProjectHook gets a specific hook for a project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#get-project-hook // https://docs.gitlab.com/ce/api/projects.html#get-project-hook
func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...OptionFunc) (*ProjectHook, *Response, error) { func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...OptionFunc) (*ProjectHook, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -810,7 +744,7 @@ func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...O ...@@ -810,7 +744,7 @@ func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...O
// AddProjectHookOptions represents the available AddProjectHook() options. // AddProjectHookOptions represents the available AddProjectHook() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#add-project-hook // https://docs.gitlab.com/ce/api/projects.html#add-project-hook
type AddProjectHookOptions struct { type AddProjectHookOptions struct {
URL *string `url:"url,omitempty" json:"url,omitempty"` URL *string `url:"url,omitempty" json:"url,omitempty"`
PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"`
...@@ -828,7 +762,7 @@ type AddProjectHookOptions struct { ...@@ -828,7 +762,7 @@ type AddProjectHookOptions struct {
// AddProjectHook adds a hook to a specified project. // AddProjectHook adds a hook to a specified project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#add-project-hook // https://docs.gitlab.com/ce/api/projects.html#add-project-hook
func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) { func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -853,7 +787,7 @@ func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOpt ...@@ -853,7 +787,7 @@ func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOpt
// EditProjectHookOptions represents the available EditProjectHook() options. // EditProjectHookOptions represents the available EditProjectHook() options.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project-hook // https://docs.gitlab.com/ce/api/projects.html#edit-project-hook
type EditProjectHookOptions struct { type EditProjectHookOptions struct {
URL *string `url:"url,omitempty" json:"url,omitempty"` URL *string `url:"url,omitempty" json:"url,omitempty"`
PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"`
...@@ -871,7 +805,7 @@ type EditProjectHookOptions struct { ...@@ -871,7 +805,7 @@ type EditProjectHookOptions struct {
// EditProjectHook edits a hook for a specified project. // EditProjectHook edits a hook for a specified project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#edit-project-hook // https://docs.gitlab.com/ce/api/projects.html#edit-project-hook
func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) { func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -897,7 +831,7 @@ func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditPr ...@@ -897,7 +831,7 @@ func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditPr
// method and can be called multiple times. Either the hook is available or not. // method and can be called multiple times. Either the hook is available or not.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#delete-project-hook // https://docs.gitlab.com/ce/api/projects.html#delete-project-hook
func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options ...OptionFunc) (*Response, error) { func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -916,7 +850,7 @@ func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options . ...@@ -916,7 +850,7 @@ func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options .
// ProjectForkRelation represents a project fork relationship. // ProjectForkRelation represents a project fork relationship.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#admin-fork-relation // https://docs.gitlab.com/ce/api/projects.html#admin-fork-relation
type ProjectForkRelation struct { type ProjectForkRelation struct {
ID int `json:"id"` ID int `json:"id"`
ForkedToProjectID int `json:"forked_to_project_id"` ForkedToProjectID int `json:"forked_to_project_id"`
...@@ -929,7 +863,7 @@ type ProjectForkRelation struct { ...@@ -929,7 +863,7 @@ type ProjectForkRelation struct {
// existing projects. // existing projects.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#create-a-forked-fromto-relation-between-existing-projects. // https://docs.gitlab.com/ce/api/projects.html#create-a-forked-fromto-relation-between-existing-projects.
func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options ...OptionFunc) (*ProjectForkRelation, *Response, error) { func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options ...OptionFunc) (*ProjectForkRelation, *Response, error) {
u := fmt.Sprintf("projects/%d/fork/%d", pid, fork) u := fmt.Sprintf("projects/%d/fork/%d", pid, fork)
...@@ -950,7 +884,7 @@ func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options . ...@@ -950,7 +884,7 @@ func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options .
// DeleteProjectForkRelation deletes an existing forked from relationship. // DeleteProjectForkRelation deletes an existing forked from relationship.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#delete-an-existing-forked-from-relationship // https://docs.gitlab.com/ce/api/projects.html#delete-an-existing-forked-from-relationship
func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...OptionFunc) (*Response, error) { func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...OptionFunc) (*Response, error) {
u := fmt.Sprintf("projects/%d/fork", pid) u := fmt.Sprintf("projects/%d/fork", pid)
...@@ -966,7 +900,7 @@ func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...OptionFu ...@@ -966,7 +900,7 @@ func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...OptionFu
// project owner of this project. // project owner of this project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#archive-a-project // https://docs.gitlab.com/ce/api/projects.html#archive-a-project
func (s *ProjectsService) ArchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) ArchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
...@@ -992,7 +926,7 @@ func (s *ProjectsService) ArchiveProject(pid interface{}, options ...OptionFunc) ...@@ -992,7 +926,7 @@ func (s *ProjectsService) ArchiveProject(pid interface{}, options ...OptionFunc)
// the project owner of this project. // the project owner of this project.
// //
// GitLab API docs: // GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/projects.md#unarchive-a-project // https://docs.gitlab.com/ce/api/projects.html#unarchive-a-project
func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
......
...@@ -182,34 +182,6 @@ func TestGetProject_byName(t *testing.T) { ...@@ -182,34 +182,6 @@ func TestGetProject_byName(t *testing.T) {
} }
} }
func TestSearchProjects(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/search/query", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"page": "2",
"per_page": "3",
"order_by": "name",
"sort": "asc",
})
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
})
opt := &SearchProjectsOptions{ListOptions{2, 3}, String("name"), String("asc")}
projects, _, err := client.Projects.SearchProjects("query", opt)
if err != nil {
t.Errorf("Projects.SearchProjects returned error: %v", err)
}
want := []*Project{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(want, projects) {
t.Errorf("Projects.SearchProjects returned %+v, want %+v", projects, want)
}
}
func TestCreateProject(t *testing.T) { func TestCreateProject(t *testing.T) {
mux, server, client := setup() mux, server, client := setup()
defer teardown(server) defer teardown(server)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment