From eb57eaf30965ba24ff669d6f9c8d11cd24951777 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sun, 19 Feb 2017 01:49:51 +0000 Subject: update dependencies --- vendor/github.com/xanzy/go-gitlab/CHANGELOG.md | 8 + vendor/github.com/xanzy/go-gitlab/branches.go | 28 +-- .../github.com/xanzy/go-gitlab/build_variables.go | 20 +- vendor/github.com/xanzy/go-gitlab/builds.go | 44 ++-- vendor/github.com/xanzy/go-gitlab/commits.go | 45 ++-- vendor/github.com/xanzy/go-gitlab/deploy_keys.go | 20 +- vendor/github.com/xanzy/go-gitlab/gitlab.go | 258 ++++++++++++++------- vendor/github.com/xanzy/go-gitlab/groups.go | 58 ++--- vendor/github.com/xanzy/go-gitlab/issues.go | 31 +-- vendor/github.com/xanzy/go-gitlab/labels.go | 20 +- .../github.com/xanzy/go-gitlab/merge_requests.go | 165 ++++--------- vendor/github.com/xanzy/go-gitlab/milestones.go | 32 +-- vendor/github.com/xanzy/go-gitlab/namespaces.go | 8 +- vendor/github.com/xanzy/go-gitlab/notes.go | 84 ++----- vendor/github.com/xanzy/go-gitlab/notifications.go | 214 +++++++++++++++++ vendor/github.com/xanzy/go-gitlab/pipelines.go | 23 +- .../github.com/xanzy/go-gitlab/project_snippets.go | 35 +-- vendor/github.com/xanzy/go-gitlab/projects.go | 135 +++++------ vendor/github.com/xanzy/go-gitlab/repositories.go | 35 +-- .../github.com/xanzy/go-gitlab/repository_files.go | 24 +- vendor/github.com/xanzy/go-gitlab/services.go | 44 ++-- vendor/github.com/xanzy/go-gitlab/session.go | 4 +- vendor/github.com/xanzy/go-gitlab/settings.go | 8 +- vendor/github.com/xanzy/go-gitlab/system_hooks.go | 16 +- vendor/github.com/xanzy/go-gitlab/tags.go | 16 +- vendor/github.com/xanzy/go-gitlab/time_stats.go | 32 +-- vendor/github.com/xanzy/go-gitlab/users.go | 92 ++++---- 27 files changed, 788 insertions(+), 711 deletions(-) create mode 100644 vendor/github.com/xanzy/go-gitlab/notifications.go (limited to 'vendor/github.com/xanzy/go-gitlab') diff --git a/vendor/github.com/xanzy/go-gitlab/CHANGELOG.md b/vendor/github.com/xanzy/go-gitlab/CHANGELOG.md index 8958062..09cb6db 100644 --- a/vendor/github.com/xanzy/go-gitlab/CHANGELOG.md +++ b/vendor/github.com/xanzy/go-gitlab/CHANGELOG.md @@ -1,6 +1,14 @@ go-github CHANGELOG =================== +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. diff --git a/vendor/github.com/xanzy/go-gitlab/branches.go b/vendor/github.com/xanzy/go-gitlab/branches.go index b8fa45d..adb4c73 100644 --- a/vendor/github.com/xanzy/go-gitlab/branches.go +++ b/vendor/github.com/xanzy/go-gitlab/branches.go @@ -47,14 +47,14 @@ func (b Branch) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#list-repository-branches -func (s *BranchesService) ListBranches(pid interface{}) ([]*Branch, *Response, error) { +func (s *BranchesService) ListBranches(pid interface{}, options ...OptionFunc) ([]*Branch, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/branches", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -72,14 +72,14 @@ func (s *BranchesService) ListBranches(pid interface{}) ([]*Branch, *Response, e // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#get-single-repository-branch -func (s *BranchesService) GetBranch(pid interface{}, branch string) (*Branch, *Response, error) { +func (s *BranchesService) GetBranch(pid interface{}, branch string, options ...OptionFunc) (*Branch, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/branches/%s", url.QueryEscape(project), branch) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -99,14 +99,14 @@ func (s *BranchesService) GetBranch(pid interface{}, branch string) (*Branch, *R // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#protect-repository-branch -func (s *BranchesService) ProtectBranch(pid interface{}, branch string) (*Branch, *Response, error) { +func (s *BranchesService) ProtectBranch(pid interface{}, branch string, options ...OptionFunc) (*Branch, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/branches/%s/protect", url.QueryEscape(project), branch) - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", u, nil, options) if err != nil { return nil, nil, err } @@ -126,16 +126,14 @@ func (s *BranchesService) ProtectBranch(pid interface{}, branch string) (*Branch // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#unprotect-repository-branch -func (s *BranchesService) UnprotectBranch( - pid interface{}, - branch string) (*Branch, *Response, error) { +func (s *BranchesService) UnprotectBranch(pid interface{}, branch string, options ...OptionFunc) (*Branch, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/branches/%s/unprotect", url.QueryEscape(project), branch) - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", u, nil, options) if err != nil { return nil, nil, err } @@ -162,16 +160,14 @@ type CreateBranchOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#create-repository-branch -func (s *BranchesService) CreateBranch( - pid interface{}, - opt *CreateBranchOptions) (*Branch, *Response, error) { +func (s *BranchesService) CreateBranch(pid interface{}, opt *CreateBranchOptions, options ...OptionFunc) (*Branch, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/branches", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -189,14 +185,14 @@ func (s *BranchesService) CreateBranch( // // GitLab API docs: // https://docs.gitlab.com/ce/api/branches.html#delete-repository-branch -func (s *BranchesService) DeleteBranch(pid interface{}, branch string) (*Response, error) { +func (s *BranchesService) DeleteBranch(pid interface{}, branch string, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/repository/branches/%s", url.QueryEscape(project), branch) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/build_variables.go b/vendor/github.com/xanzy/go-gitlab/build_variables.go index 5234a01..a1bdf7f 100644 --- a/vendor/github.com/xanzy/go-gitlab/build_variables.go +++ b/vendor/github.com/xanzy/go-gitlab/build_variables.go @@ -29,14 +29,14 @@ func (v BuildVariable) String() string { // // Gitlab API Docs: // https://docs.gitlab.com/ce/api/build_variables.html#list-project-variables -func (s *BuildVariablesService) ListBuildVariables(pid interface{}) ([]*BuildVariable, *Response, error) { +func (s *BuildVariablesService) ListBuildVariables(pid interface{}, options ...OptionFunc) ([]*BuildVariable, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/variables", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -54,14 +54,14 @@ func (s *BuildVariablesService) ListBuildVariables(pid interface{}) ([]*BuildVar // // Gitlab API Docs: // https://docs.gitlab.com/ce/api/build_variables.html#show-variable-details -func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string) (*BuildVariable, *Response, error) { +func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string, options ...OptionFunc) (*BuildVariable, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -79,14 +79,14 @@ func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string) (* // // Gitlab API Docs: // https://docs.gitlab.com/ce/api/build_variables.html#create-variable -func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value string) (*BuildVariable, *Response, error) { +func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value string, options ...OptionFunc) (*BuildVariable, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/variables", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, BuildVariable{key, value}) + req, err := s.client.NewRequest("POST", u, BuildVariable{key, value}, options) if err != nil { return nil, nil, err } @@ -105,14 +105,14 @@ func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value // // Gitlab API Docs: // https://docs.gitlab.com/ce/api/build_variables.html#update-variable -func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value string) (*BuildVariable, *Response, error) { +func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value string, options ...OptionFunc) (*BuildVariable, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key) - req, err := s.client.NewRequest("PUT", u, BuildVariable{key, value}) + req, err := s.client.NewRequest("PUT", u, BuildVariable{key, value}, options) if err != nil { return nil, nil, err } @@ -130,14 +130,14 @@ func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value // // Gitlab API Docs: // https://docs.gitlab.com/ce/api/build_variables.html#remove-variable -func (s *BuildVariablesService) RemoveBuildVariable(pid interface{}, key string) (*Response, error) { +func (s *BuildVariablesService) RemoveBuildVariable(pid interface{}, key string, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/builds.go b/vendor/github.com/xanzy/go-gitlab/builds.go index a26ead5..dfee85b 100644 --- a/vendor/github.com/xanzy/go-gitlab/builds.go +++ b/vendor/github.com/xanzy/go-gitlab/builds.go @@ -73,14 +73,14 @@ type Build struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#list-project-builds -func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptions) ([]Build, *Response, error) { +func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptions, options ...OptionFunc) ([]Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opts) + req, err := s.client.NewRequest("GET", u, opts, options) if err != nil { return nil, nil, err } @@ -99,14 +99,14 @@ func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptio // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#list-commit-builds -func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *ListBuildsOptions) ([]Build, *Response, error) { +func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *ListBuildsOptions, options ...OptionFunc) ([]Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s/builds", project, sha) - req, err := s.client.NewRequest("GET", u, opts) + req, err := s.client.NewRequest("GET", u, opts, options) if err != nil { return nil, nil, err } @@ -124,14 +124,14 @@ func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *List // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#get-a-single-build -func (s *BuildsService) GetBuild(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) GetBuild(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d", project, buildID) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -149,14 +149,14 @@ func (s *BuildsService) GetBuild(pid interface{}, buildID int) (*Build, *Respons // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#get-build-artifacts -func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int) (io.Reader, *Response, error) { +func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int, options ...OptionFunc) (io.Reader, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/artifacts", project, buildID) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -175,14 +175,14 @@ func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int) (io.Read // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#download-the-artifacts-file -func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, job string) (io.Reader, *Response, error) { +func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, job string, options ...OptionFunc) (io.Reader, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/artifacts/%s/download?job=%s", project, refName, job) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -200,14 +200,14 @@ func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, j // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#get-a-trace-file -func (s *BuildsService) GetTraceFile(pid interface{}, buildID int) (io.Reader, *Response, error) { +func (s *BuildsService) GetTraceFile(pid interface{}, buildID int, options ...OptionFunc) (io.Reader, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/trace", project, buildID) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -225,14 +225,14 @@ func (s *BuildsService) GetTraceFile(pid interface{}, buildID int) (io.Reader, * // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#cancel-a-build -func (s *BuildsService) CancelBuild(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) CancelBuild(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/cancel", project, buildID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -250,14 +250,14 @@ func (s *BuildsService) CancelBuild(pid interface{}, buildID int) (*Build, *Resp // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#retry-a-build -func (s *BuildsService) RetryBuild(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) RetryBuild(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/retry", project, buildID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -276,14 +276,14 @@ func (s *BuildsService) RetryBuild(pid interface{}, buildID int) (*Build, *Respo // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#erase-a-build -func (s *BuildsService) EraseBuild(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) EraseBuild(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/erase", project, buildID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -302,14 +302,14 @@ func (s *BuildsService) EraseBuild(pid interface{}, buildID int) (*Build, *Respo // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#keep-artifacts -func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/artifacts/keep", project, buildID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -327,14 +327,14 @@ func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int) (*Build, *Re // // GitLab API docs: // https://docs.gitlab.com/ce/api/builds.html#play-a-build -func (s *BuildsService) PlayBuild(pid interface{}, buildID int) (*Build, *Response, error) { +func (s *BuildsService) PlayBuild(pid interface{}, buildID int, options ...OptionFunc) (*Build, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/builds/%d/play", project, buildID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/commits.go b/vendor/github.com/xanzy/go-gitlab/commits.go index c61a6b7..7860f58 100644 --- a/vendor/github.com/xanzy/go-gitlab/commits.go +++ b/vendor/github.com/xanzy/go-gitlab/commits.go @@ -63,16 +63,14 @@ type ListCommitsOptions struct { // ListCommits gets a list of repository commits in a project. // // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#list-commits -func (s *CommitsService) ListCommits( - pid interface{}, - opt *ListCommitsOptions) ([]*Commit, *Response, error) { +func (s *CommitsService) ListCommits(pid interface{}, opt *ListCommitsOptions, options ...OptionFunc) ([]*Commit, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -90,16 +88,14 @@ func (s *CommitsService) ListCommits( // branch or tag. // // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#get-a-single-commit -func (s *CommitsService) GetCommit( - pid interface{}, - sha string) (*Commit, *Response, error) { +func (s *CommitsService) GetCommit(pid interface{}, sha string, options ...OptionFunc) (*Commit, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -135,16 +131,14 @@ func (d Diff) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/commits.html#get-the-diff-of-a-commit -func (s *CommitsService) GetCommitDiff( - pid interface{}, - sha string) ([]*Diff, *Response, error) { +func (s *CommitsService) GetCommitDiff(pid interface{}, sha string, options ...OptionFunc) ([]*Diff, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s/diff", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -188,16 +182,14 @@ func (c CommitComment) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/commits.html#get-the-comments-of-a-commit -func (s *CommitsService) GetCommitComments( - pid interface{}, - sha string) ([]*CommitComment, *Response, error) { +func (s *CommitsService) GetCommitComments(pid interface{}, sha string, options ...OptionFunc) ([]*CommitComment, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -229,17 +221,14 @@ type PostCommitCommentOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit -func (s *CommitsService) PostCommitComment( - pid interface{}, - sha string, - opt *PostCommitCommentOptions) (*CommitComment, *Response, error) { +func (s *CommitsService) PostCommitComment(pid interface{}, sha string, opt *PostCommitCommentOptions, options ...OptionFunc) (*CommitComment, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -283,17 +272,14 @@ type CommitStatus struct { // GetCommitStatuses gets the statuses of a commit in a project. // // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#get-the-status-of-a-commit -func (s *CommitsService) GetCommitStatuses( - pid interface{}, - sha string, - opt *GetCommitStatusesOptions) ([]*CommitStatus, *Response, error) { +func (s *CommitsService) GetCommitStatuses(pid interface{}, sha string, opt *GetCommitStatusesOptions, options ...OptionFunc) ([]*CommitStatus, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/commits/%s/statuses", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -334,17 +320,14 @@ const ( // SetCommitStatus sets the status of a commit in a project. // // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit -func (s *CommitsService) SetCommitStatus( - pid interface{}, - sha string, - opt *SetCommitStatusOptions) (*CommitStatus, *Response, error) { +func (s *CommitsService) SetCommitStatus(pid interface{}, sha string, opt *SetCommitStatusOptions, options ...OptionFunc) (*CommitStatus, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/statuses/%s", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/deploy_keys.go b/vendor/github.com/xanzy/go-gitlab/deploy_keys.go index 1dcf99c..e964e18 100644 --- a/vendor/github.com/xanzy/go-gitlab/deploy_keys.go +++ b/vendor/github.com/xanzy/go-gitlab/deploy_keys.go @@ -46,14 +46,14 @@ func (k DeployKey) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/deploy_keys.html#list-deploy-keys -func (s *DeployKeysService) ListDeployKeys(pid interface{}) ([]*DeployKey, *Response, error) { +func (s *DeployKeysService) ListDeployKeys(pid interface{}, options ...OptionFunc) ([]*DeployKey, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/keys", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -71,16 +71,14 @@ func (s *DeployKeysService) ListDeployKeys(pid interface{}) ([]*DeployKey, *Resp // // GitLab API docs: // https://docs.gitlab.com/ce/api/deploy_keys.html#single-deploy-key -func (s *DeployKeysService) GetDeployKey( - pid interface{}, - deployKey int) (*DeployKey, *Response, error) { +func (s *DeployKeysService) GetDeployKey(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/keys/%d", url.QueryEscape(project), deployKey) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -109,16 +107,14 @@ type AddDeployKeyOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/deploy_keys.html#add-deploy-key -func (s *DeployKeysService) AddDeployKey( - pid interface{}, - opt *AddDeployKeyOptions) (*DeployKey, *Response, error) { +func (s *DeployKeysService) AddDeployKey(pid interface{}, opt *AddDeployKeyOptions, options ...OptionFunc) (*DeployKey, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/keys", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -136,14 +132,14 @@ func (s *DeployKeysService) AddDeployKey( // // GitLab API docs: // https://docs.gitlab.com/ce/api/deploy_keys.html#delete-deploy-key -func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int) (*Response, error) { +func (s *DeployKeysService) DeleteDeployKey(pid interface{}, deployKey int, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/keys/%d", url.QueryEscape(project), deployKey) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/gitlab.go b/vendor/github.com/xanzy/go-gitlab/gitlab.go index 296e32c..35d65a4 100644 --- a/vendor/github.com/xanzy/go-gitlab/gitlab.go +++ b/vendor/github.com/xanzy/go-gitlab/gitlab.go @@ -24,6 +24,7 @@ import ( "io/ioutil" "net/http" "net/url" + "sort" "strconv" "strings" @@ -65,22 +66,66 @@ const ( OwnerPermission AccessLevelValue = 50 ) -// NotificationLevelValue represents a notification level within Gitlab. -// -// GitLab API docs: https://docs.gitlab.com/ce/api/ +// NotificationLevelValue represents a notification level. type NotificationLevelValue int -// List of available notification levels -// -// GitLab API docs: https://docs.gitlab.com/ce/api/ +// String implements the fmt.Stringer interface. +func (l NotificationLevelValue) String() string { + return notificationLevelNames[l] +} + +// MarshalJSON implements the json.Marshaler interface. +func (l NotificationLevelValue) MarshalJSON() ([]byte, error) { + return json.Marshal(l.String()) +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (l *NotificationLevelValue) UnmarshalJSON(data []byte) error { + var raw interface{} + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + switch raw := raw.(type) { + case float64: + *l = NotificationLevelValue(raw) + case string: + *l = notificationLevelTypes[raw] + default: + return fmt.Errorf("json: cannot unmarshal %T into Go value of type %T", raw, *l) + } + + return nil +} + +// List of valid notification levels. const ( - DisabledNotifications NotificationLevelValue = iota - ParticipatingNotifications - WatchNotifications - GlobalNotifications - MentionNotifications + DisabledNotificationLevel NotificationLevelValue = iota + ParticipatingNotificationLevel + WatchNotificationLevel + GlobalNotificationLevel + MentionNotificationLevel + CustomNotificationLevel ) +var notificationLevelNames = [...]string{ + "disabled", + "participating", + "watch", + "global", + "mention", + "custom", +} + +var notificationLevelTypes = map[string]NotificationLevelValue{ + "disabled": DisabledNotificationLevel, + "participating": ParticipatingNotificationLevel, + "watch": WatchNotificationLevel, + "global": GlobalNotificationLevel, + "mention": MentionNotificationLevel, + "custom": CustomNotificationLevel, +} + // VisibilityLevelValue represents a visibility level within GitLab. // // GitLab API docs: https://docs.gitlab.com/ce/api/ @@ -115,30 +160,31 @@ type Client struct { UserAgent string // Services used for talking to different parts of the GitLab API. - Branches *BranchesService - BuildVariables *BuildVariablesService - Builds *BuildsService - Commits *CommitsService - DeployKeys *DeployKeysService - Groups *GroupsService - Issues *IssuesService - Labels *LabelsService - MergeRequests *MergeRequestsService - Milestones *MilestonesService - Namespaces *NamespacesService - Notes *NotesService - Projects *ProjectsService - ProjectSnippets *ProjectSnippetsService - Pipelines *PipelinesService - Repositories *RepositoriesService - RepositoryFiles *RepositoryFilesService - Services *ServicesService - Session *SessionService - Settings *SettingsService - SystemHooks *SystemHooksService - Tags *TagsService - TimeStats *TimeStatsService - Users *UsersService + Branches *BranchesService + BuildVariables *BuildVariablesService + Builds *BuildsService + Commits *CommitsService + DeployKeys *DeployKeysService + Groups *GroupsService + Issues *IssuesService + Labels *LabelsService + MergeRequests *MergeRequestsService + Milestones *MilestonesService + Namespaces *NamespacesService + Notes *NotesService + NotificationSettings *NotificationSettingsService + Projects *ProjectsService + ProjectSnippets *ProjectSnippetsService + Pipelines *PipelinesService + Repositories *RepositoriesService + RepositoryFiles *RepositoryFilesService + Services *ServicesService + Session *SessionService + Settings *SettingsService + SystemHooks *SystemHooksService + Tags *TagsService + TimeStats *TimeStatsService + Users *UsersService } // ListOptions specifies the optional parameters to various List methods that @@ -186,8 +232,9 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie c.Labels = &LabelsService{client: c} c.MergeRequests = &MergeRequestsService{client: c} c.Milestones = &MilestonesService{client: c} - c.Notes = &NotesService{client: c} c.Namespaces = &NamespacesService{client: c} + c.Notes = &NotesService{client: c} + c.NotificationSettings = &NotificationSettingsService{client: c} c.Projects = &ProjectsService{client: c} c.ProjectSnippets = &ProjectSnippetsService{client: c} c.Pipelines = &PipelinesService{client: c} @@ -228,7 +275,7 @@ func (c *Client) SetBaseURL(urlStr string) error { // Relative URL paths should always be specified without a preceding slash. If // specified, the value pointed to by body is JSON encoded and included as the // request body. -func (c *Client) NewRequest(method, path string, opt interface{}) (*http.Request, error) { +func (c *Client) NewRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error) { u := *c.baseURL // Set the encoded opaque data u.Opaque = c.baseURL.Path + path @@ -251,6 +298,12 @@ func (c *Client) NewRequest(method, path string, opt interface{}) (*http.Request Host: u.Host, } + for _, fn := range options { + if err := fn(req); err != nil { + return nil, err + } + } + if method == "POST" || method == "PUT" { bodyBytes, err := json.Marshal(opt) if err != nil { @@ -397,61 +450,102 @@ func parseID(id interface{}) (string, error) { // GitLab API docs: // https://docs.gitlab.com/ce/api/README.html#data-validation-and-error-reporting type ErrorResponse struct { - Response *http.Response // HTTP response that caused this error - Message string `json:"message"` // error message - Errors []Error `json:"errors"` // more detail on individual errors + Response *http.Response + Message string } -func (r *ErrorResponse) Error() string { - path, _ := url.QueryUnescape(r.Response.Request.URL.Opaque) - ru := fmt.Sprintf("%s://%s%s", r.Response.Request.URL.Scheme, r.Response.Request.URL.Host, path) - - return fmt.Sprintf("%v %s: %d %v %+v", - r.Response.Request.Method, ru, r.Response.StatusCode, r.Message, r.Errors) +func (e *ErrorResponse) Error() string { + path, _ := url.QueryUnescape(e.Response.Request.URL.Opaque) + u := fmt.Sprintf("%s://%s%s", e.Response.Request.URL.Scheme, e.Response.Request.URL.Host, path) + return fmt.Sprintf("%s %s: %d %s", e.Response.Request.Method, u, e.Response.StatusCode, e.Message) } -// An Error reports more details on an individual error in an ErrorResponse. -// These are the possible validation error codes: -// -// missing: -// resource does not exist -// missing_field: -// a required field on a resource has not been set -// invalid: -// the formatting of a field is invalid -// already_exists: -// another resource has the same valid as this field -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/README.html#data-validation-and-error-reporting -type Error struct { - Resource string `json:"resource"` // resource on which the error occurred - Field string `json:"field"` // field on which the error occurred - Code string `json:"code"` // validation error code -} - -func (e *Error) Error() string { - return fmt.Sprintf("%v error caused by %v field on %v resource", - e.Code, e.Field, e.Resource) -} - -// CheckResponse checks the API response for errors, and returns them if -// present. A response is considered an error if it has a status code outside -// the 200 range. API error responses are expected to have either no response -// body, or a JSON response body that maps to ErrorResponse. Any other -// response body will be silently ignored. +// CheckResponse checks the API response for errors, and returns them if present. func CheckResponse(r *http.Response) error { - if c := r.StatusCode; 200 <= c && c <= 299 { + switch r.StatusCode { + case 200, 201, 304: return nil } + errorResponse := &ErrorResponse{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && data != nil { - json.Unmarshal(data, errorResponse) + var raw interface{} + if err := json.Unmarshal(data, &raw); err != nil { + errorResponse.Message = "failed to parse unknown error format" + } + + errorResponse.Message = parseError(raw) } + return errorResponse } +// Format: +// { +// "message": { +// "": [ +// "", +// "", +// ... +// ], +// "": { +// "": [ +// "", +// "", +// ... +// ], +// } +// }, +// "error": "" +// } +func parseError(raw interface{}) string { + switch raw := raw.(type) { + case string: + return raw + + case []interface{}: + var errs []string + for _, v := range raw { + errs = append(errs, parseError(v)) + } + return fmt.Sprintf("[%s]", strings.Join(errs, ", ")) + + case map[string]interface{}: + var errs []string + for k, v := range raw { + errs = append(errs, fmt.Sprintf("{%s: %s}", k, parseError(v))) + } + sort.Strings(errs) + return fmt.Sprintf("%s", strings.Join(errs, ", ")) + + default: + return fmt.Sprintf("failed to parse unexpected error type: %T", raw) + } +} + +// OptionFunc can be passed to all API requests to make the API call as if you were +// another user, provided your private token is from an administrator account. +// +// GitLab docs: https://docs.gitlab.com/ce/api/README.html#sudo +type OptionFunc func(*http.Request) error + +// WithSudo takes either a username or user ID and sets the SUDO request header +func WithSudo(uid interface{}) OptionFunc { + return func(req *http.Request) error { + switch uid := uid.(type) { + case int: + req.Header.Set("SUDO", strconv.Itoa(uid)) + return nil + case string: + req.Header.Set("SUDO", uid) + return nil + default: + return fmt.Errorf("uid must be either a username or user ID") + } + } +} + // Bool is a helper routine that allocates a new bool value // to store v and returns a pointer to it. func Bool(v bool) *bool { @@ -485,6 +579,14 @@ func AccessLevel(v AccessLevelValue) *AccessLevelValue { return p } +// NotificationLevel is a helper routine that allocates a new NotificationLevelValue +// to store v and returns a pointer to it. +func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue { + p := new(NotificationLevelValue) + *p = v + return p +} + // VisibilityLevel is a helper routine that allocates a new VisibilityLevelValue // to store v and returns a pointer to it. func VisibilityLevel(v VisibilityLevelValue) *VisibilityLevelValue { diff --git a/vendor/github.com/xanzy/go-gitlab/groups.go b/vendor/github.com/xanzy/go-gitlab/groups.go index 994f62c..060079e 100644 --- a/vendor/github.com/xanzy/go-gitlab/groups.go +++ b/vendor/github.com/xanzy/go-gitlab/groups.go @@ -52,8 +52,8 @@ type ListGroupsOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#list-project-groups -func (s *GroupsService) ListGroups(opt *ListGroupsOptions) ([]*Group, *Response, error) { - req, err := s.client.NewRequest("GET", "groups", opt) +func (s *GroupsService) ListGroups(opt *ListGroupsOptions, options ...OptionFunc) ([]*Group, *Response, error) { + req, err := s.client.NewRequest("GET", "groups", opt, options) if err != nil { return nil, nil, err } @@ -70,14 +70,14 @@ func (s *GroupsService) ListGroups(opt *ListGroupsOptions) ([]*Group, *Response, // GetGroup gets all details of a group. // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#details-of-a-group -func (s *GroupsService) GetGroup(gid interface{}) (*Group, *Response, error) { +func (s *GroupsService) GetGroup(gid interface{}, options ...OptionFunc) (*Group, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s", group) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -105,8 +105,8 @@ type CreateGroupOptions struct { // create groups. // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#new-group -func (s *GroupsService) CreateGroup(opt *CreateGroupOptions) (*Group, *Response, error) { - req, err := s.client.NewRequest("POST", "groups", opt) +func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...OptionFunc) (*Group, *Response, error) { + req, err := s.client.NewRequest("POST", "groups", opt, options) if err != nil { return nil, nil, err } @@ -125,14 +125,14 @@ func (s *GroupsService) CreateGroup(opt *CreateGroupOptions) (*Group, *Response, // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#transfer-project-to-group -func (s *GroupsService) TransferGroup(gid interface{}, project int) (*Group, *Response, error) { +func (s *GroupsService) TransferGroup(gid interface{}, project int, options ...OptionFunc) (*Group, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/projects/%d", group, project) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -149,14 +149,14 @@ func (s *GroupsService) TransferGroup(gid interface{}, project int) (*Group, *Re // DeleteGroup removes group with all projects inside. // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#remove-group -func (s *GroupsService) DeleteGroup(gid interface{}) (*Response, error) { +func (s *GroupsService) DeleteGroup(gid interface{}, options ...OptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { return nil, err } u := fmt.Sprintf("groups/%s", group) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -167,13 +167,13 @@ func (s *GroupsService) DeleteGroup(gid interface{}) (*Response, error) { // SearchGroup get all groups that match your string in their name or path. // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#search-for-group -func (s *GroupsService) SearchGroup(query string) ([]*Group, *Response, error) { +func (s *GroupsService) SearchGroup(query string, options ...OptionFunc) ([]*Group, *Response, error) { var q struct { Search string `url:"search,omitempty" json:"search,omitempty"` } q.Search = query - req, err := s.client.NewRequest("GET", "groups", &q) + req, err := s.client.NewRequest("GET", "groups", &q, options) if err != nil { return nil, nil, err } @@ -214,14 +214,14 @@ type ListGroupMembersOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#list-group-members -func (s *GroupsService) ListGroupMembers(gid interface{}, opt *ListGroupMembersOptions) ([]*GroupMember, *Response, error) { +func (s *GroupsService) ListGroupMembers(gid interface{}, opt *ListGroupMembersOptions, options ...OptionFunc) ([]*GroupMember, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/members", group) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -235,18 +235,27 @@ func (s *GroupsService) ListGroupMembers(gid interface{}, opt *ListGroupMembersO return g, resp, err } +// ListGroupProjectsOptions represents the available ListGroupProjects() +// options. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/groups.html#list-a-group-s-projects +type ListGroupProjectsOptions struct { + ListOptions +} + // ListGroupProjects get a list of group projects // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#list-a-group-s-projects -func (s *GroupsService) ListGroupProjects(gid interface{}) ([]*Project, *Response, error) { +func (s *GroupsService) ListGroupProjects(gid interface{}, opt *ListGroupProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/projects", group) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -272,16 +281,14 @@ type AddGroupMemberOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#list-group-members -func (s *GroupsService) AddGroupMember( - gid interface{}, - opt *AddGroupMemberOptions) (*GroupMember, *Response, error) { +func (s *GroupsService) AddGroupMember(gid interface{}, opt *AddGroupMemberOptions, options ...OptionFunc) (*GroupMember, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/members", group) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -308,17 +315,14 @@ type UpdateGroupMemberOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#list-group-members -func (s *GroupsService) UpdateGroupMember( - gid interface{}, - user int, - opt *UpdateGroupMemberOptions) (*GroupMember, *Response, error) { +func (s *GroupsService) UpdateGroupMember(gid interface{}, user int, opt *UpdateGroupMemberOptions, options ...OptionFunc) (*GroupMember, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/members/%d", group, user) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -336,14 +340,14 @@ func (s *GroupsService) UpdateGroupMember( // // GitLab API docs: // https://docs.gitlab.com/ce/api/groups.html#remove-user-from-user-team -func (s *GroupsService) RemoveGroupMember(gid interface{}, user int) (*Response, error) { +func (s *GroupsService) RemoveGroupMember(gid interface{}, user int, options ...OptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { return nil, err } u := fmt.Sprintf("groups/%s/members/%d", group, user) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/issues.go b/vendor/github.com/xanzy/go-gitlab/issues.go index 176628c..0a286c2 100644 --- a/vendor/github.com/xanzy/go-gitlab/issues.go +++ b/vendor/github.com/xanzy/go-gitlab/issues.go @@ -96,8 +96,8 @@ type ListIssuesOptions struct { // takes pagination parameters page and per_page to restrict the list of issues. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-issues -func (s *IssuesService) ListIssues(opt *ListIssuesOptions) ([]*Issue, *Response, error) { - req, err := s.client.NewRequest("GET", "issues", opt) +func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) { + req, err := s.client.NewRequest("GET", "issues", opt, options) if err != nil { return nil, nil, err } @@ -128,16 +128,14 @@ type ListProjectIssuesOptions struct { // pagination parameters page and per_page to return the list of project issues. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-project-issues -func (s *IssuesService) ListProjectIssues( - pid interface{}, - opt *ListProjectIssuesOptions) ([]*Issue, *Response, error) { +func (s *IssuesService) ListProjectIssues(pid interface{}, opt *ListProjectIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -154,14 +152,14 @@ func (s *IssuesService) ListProjectIssues( // GetIssue gets a single project issue. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#single-issues -func (s *IssuesService) GetIssue(pid interface{}, issue int) (*Issue, *Response, error) { +func (s *IssuesService) GetIssue(pid interface{}, issue int, options ...OptionFunc) (*Issue, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -189,16 +187,14 @@ type CreateIssueOptions struct { // CreateIssue creates a new project issue. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#new-issues -func (s *IssuesService) CreateIssue( - pid interface{}, - opt *CreateIssueOptions) (*Issue, *Response, error) { +func (s *IssuesService) CreateIssue(pid interface{}, opt *CreateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -228,17 +224,14 @@ type UpdateIssueOptions struct { // to mark an issue as closed. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#edit-issues -func (s *IssuesService) UpdateIssue( - pid interface{}, - issue int, - opt *UpdateIssueOptions) (*Issue, *Response, error) { +func (s *IssuesService) UpdateIssue(pid interface{}, issue int, opt *UpdateIssueOptions, options ...OptionFunc) (*Issue, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -255,14 +248,14 @@ func (s *IssuesService) UpdateIssue( // DeleteIssue deletes a single project issue. // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#delete-an-issue -func (s *IssuesService) DeleteIssue(pid interface{}, issue int) (*Response, error) { +func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/issues/%d", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/labels.go b/vendor/github.com/xanzy/go-gitlab/labels.go index 7063da9..8d571b7 100644 --- a/vendor/github.com/xanzy/go-gitlab/labels.go +++ b/vendor/github.com/xanzy/go-gitlab/labels.go @@ -48,14 +48,14 @@ func (l Label) String() string { // ListLabels gets all labels for given project. // // GitLab API docs: https://docs.gitlab.com/ce/api/labels.html#list-labels -func (s *LabelsService) ListLabels(pid interface{}) ([]*Label, *Response, error) { +func (s *LabelsService) ListLabels(pid interface{}, options ...OptionFunc) ([]*Label, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/labels", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -82,16 +82,14 @@ type CreateLabelOptions struct { // color. // // GitLab API docs: https://docs.gitlab.com/ce/api/labels.html#create-a-new-label -func (s *LabelsService) CreateLabel( - pid interface{}, - opt *CreateLabelOptions) (*Label, *Response, error) { +func (s *LabelsService) CreateLabel(pid interface{}, opt *CreateLabelOptions, options ...OptionFunc) (*Label, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/labels", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -115,14 +113,14 @@ type DeleteLabelOptions struct { // DeleteLabel deletes a label given by its name. // // GitLab API docs: https://docs.gitlab.com/ce/api/labels.html#delete-a-label -func (s *LabelsService) DeleteLabel(pid interface{}, opt *DeleteLabelOptions) (*Response, error) { +func (s *LabelsService) DeleteLabel(pid interface{}, opt *DeleteLabelOptions, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/labels", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, opt) + req, err := s.client.NewRequest("DELETE", u, opt, options) if err != nil { return nil, err } @@ -144,16 +142,14 @@ type UpdateLabelOptions struct { // one parameter is required, to update the label. // // GitLab API docs: https://docs.gitlab.com/ce/api/labels.html#edit-an-existing-label -func (s *LabelsService) UpdateLabel( - pid interface{}, - opt *UpdateLabelOptions) (*Label, *Response, error) { +func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, options ...OptionFunc) (*Label, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/labels", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/merge_requests.go b/vendor/github.com/xanzy/go-gitlab/merge_requests.go index b135d9d..1d15406 100644 --- a/vendor/github.com/xanzy/go-gitlab/merge_requests.go +++ b/vendor/github.com/xanzy/go-gitlab/merge_requests.go @@ -118,16 +118,14 @@ type ListMergeRequestsOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/merge_requests.html#list-merge-requests -func (s *MergeRequestsService) ListMergeRequests( - pid interface{}, - opt *ListMergeRequestsOptions) ([]*MergeRequest, *Response, error) { +func (s *MergeRequestsService) ListMergeRequests(pid interface{}, opt *ListMergeRequestsOptions, options ...OptionFunc) ([]*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/merge_requests", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -145,16 +143,14 @@ func (s *MergeRequestsService) ListMergeRequests( // // GitLab API docs: // https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr -func (s *MergeRequestsService) GetMergeRequest( - pid interface{}, - mergeRequest int) (*MergeRequest, *Response, error) { +func (s *MergeRequestsService) GetMergeRequest(pid interface{}, mergeRequest int, options ...OptionFunc) (*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/merge_request/%d", url.QueryEscape(project), mergeRequest) + u := fmt.Sprintf("projects/%s/merge_requests/%d", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -168,21 +164,44 @@ func (s *MergeRequestsService) GetMergeRequest( return m, resp, err } +// GetMergeRequestCommits gets a list of merge request commits. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-commits +func (s *MergeRequestsService) GetMergeRequestCommits(pid interface{}, mergeRequest int, options ...OptionFunc) ([]*Commit, *Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("projects/%s/merge_requests/%d/commits", url.QueryEscape(project), mergeRequest) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + var c []*Commit + resp, err := s.client.Do(req, &c) + if err != nil { + return nil, resp, err + } + + return c, resp, err +} + // 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) (*MergeRequest, *Response, error) { +func (s *MergeRequestsService) GetMergeRequestChanges(pid interface{}, mergeRequest int, options ...OptionFunc) (*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/merge_request/%d/changes", url.QueryEscape(project), mergeRequest) + u := fmt.Sprintf("projects/%s/merge_requests/%d/changes", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -214,16 +233,14 @@ type CreateMergeRequestOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/merge_requests.html#create-mr -func (s *MergeRequestsService) CreateMergeRequest( - pid interface{}, - opt *CreateMergeRequestOptions) (*MergeRequest, *Response, error) { +func (s *MergeRequestsService) CreateMergeRequest(pid interface{}, opt *CreateMergeRequestOptions, options ...OptionFunc) (*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/merge_requests", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -254,17 +271,14 @@ type UpdateMergeRequestOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/merge_requests.html#update-mr -func (s *MergeRequestsService) UpdateMergeRequest( - pid interface{}, - mergeRequest int, - opt *UpdateMergeRequestOptions) (*MergeRequest, *Response, error) { +func (s *MergeRequestsService) UpdateMergeRequest(pid interface{}, mergeRequest int, opt *UpdateMergeRequestOptions, options ...OptionFunc) (*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/merge_request/%d", url.QueryEscape(project), mergeRequest) + u := fmt.Sprintf("projects/%s/merge_requests/%d", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -297,17 +311,14 @@ type AcceptMergeRequestOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/merge_requests.html#accept-mr -func (s *MergeRequestsService) AcceptMergeRequest( - pid interface{}, - mergeRequest int, - opt *AcceptMergeRequestOptions) (*MergeRequest, *Response, error) { +func (s *MergeRequestsService) AcceptMergeRequest(pid interface{}, mergeRequest int, opt *AcceptMergeRequestOptions, options ...OptionFunc) (*MergeRequest, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/merge_request/%d/merge", url.QueryEscape(project), mergeRequest) + u := fmt.Sprintf("projects/%s/merge_requests/%d/merge", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -320,97 +331,3 @@ func (s *MergeRequestsService) AcceptMergeRequest( return m, resp, err } - -// MergeRequestComment represents a GitLab merge request comment. -// -// GitLab API docs: https://docs.gitlab.com/ce/api/merge_requests.html -type MergeRequestComment struct { - Note string `json:"note"` - Author struct { - ID int `json:"id"` - Username string `json:"username"` - Email string `json:"email"` - Name string `json:"name"` - State string `json:"state"` - CreatedAt *time.Time `json:"created_at"` - } `json:"author"` -} - -func (m MergeRequestComment) String() string { - return Stringify(m) -} - -// GetMergeRequestCommentsOptions represents the available GetMergeRequestComments() -// options. -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/merge_requests.html#get-the-comments-on-a-mr -type GetMergeRequestCommentsOptions struct { - ListOptions -} - -// GetMergeRequestComments gets all the comments associated with a merge -// request. -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/merge_requests.html#get-the-comments-on-a-mr -func (s *MergeRequestsService) GetMergeRequestComments( - pid interface{}, - mergeRequest int, - opt *GetMergeRequestCommentsOptions) ([]*MergeRequestComment, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_request/%d/comments", url.QueryEscape(project), mergeRequest) - - req, err := s.client.NewRequest("GET", u, opt) - if err != nil { - return nil, nil, err - } - - var c []*MergeRequestComment - resp, err := s.client.Do(req, &c) - if err != nil { - return nil, resp, err - } - - return c, resp, err -} - -// PostMergeRequestCommentOptions represents the available -// PostMergeRequestComment() options. -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/commits.html#post-comment-to-mr -type PostMergeRequestCommentOptions struct { - Note *string `url:"note,omitempty" json:"note,omitempty"` -} - -// PostMergeRequestComment dds a comment to a merge request. -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/commits.html#post-comment-to-mr -func (s *MergeRequestsService) PostMergeRequestComment( - pid interface{}, - mergeRequest int, - opt *PostMergeRequestCommentOptions) (*MergeRequestComment, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_request/%d/comments", url.QueryEscape(project), mergeRequest) - - req, err := s.client.NewRequest("POST", u, opt) - if err != nil { - return nil, nil, err - } - - c := new(MergeRequestComment) - resp, err := s.client.Do(req, c) - if err != nil { - return nil, resp, err - } - - return c, resp, err -} diff --git a/vendor/github.com/xanzy/go-gitlab/milestones.go b/vendor/github.com/xanzy/go-gitlab/milestones.go index e570ca5..eeaf9cc 100644 --- a/vendor/github.com/xanzy/go-gitlab/milestones.go +++ b/vendor/github.com/xanzy/go-gitlab/milestones.go @@ -63,16 +63,14 @@ type ListMilestonesOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/milestones.html#list-project-milestones -func (s *MilestonesService) ListMilestones( - pid interface{}, - opt *ListMilestonesOptions) ([]*Milestone, *Response, error) { +func (s *MilestonesService) ListMilestones(pid interface{}, opt *ListMilestonesOptions, options ...OptionFunc) ([]*Milestone, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/milestones", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -90,16 +88,14 @@ func (s *MilestonesService) ListMilestones( // // GitLab API docs: // https://docs.gitlab.com/ce/api/milestones.html#get-single-milestone -func (s *MilestonesService) GetMilestone( - pid interface{}, - milestone int) (*Milestone, *Response, error) { +func (s *MilestonesService) GetMilestone(pid interface{}, milestone int, options ...OptionFunc) (*Milestone, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/milestones/%d", url.QueryEscape(project), milestone) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -128,16 +124,14 @@ type CreateMilestoneOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/milestones.html#create-new-milestone -func (s *MilestonesService) CreateMilestone( - pid interface{}, - opt *CreateMilestoneOptions) (*Milestone, *Response, error) { +func (s *MilestonesService) CreateMilestone(pid interface{}, opt *CreateMilestoneOptions, options ...OptionFunc) (*Milestone, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/milestones", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -167,17 +161,14 @@ type UpdateMilestoneOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/milestones.html#edit-milestone -func (s *MilestonesService) UpdateMilestone( - pid interface{}, - milestone int, - opt *UpdateMilestoneOptions) (*Milestone, *Response, error) { +func (s *MilestonesService) UpdateMilestone(pid interface{}, milestone int, opt *UpdateMilestoneOptions, options ...OptionFunc) (*Milestone, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/milestones/%d", url.QueryEscape(project), milestone) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -203,17 +194,14 @@ type GetMilestoneIssuesOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/milestones.html#get-all-issues-assigned-to-a-single-milestone -func (s *MilestonesService) GetMilestoneIssues( - pid interface{}, - milestone int, - opt *GetMilestoneIssuesOptions) ([]*Issue, *Response, error) { +func (s *MilestonesService) GetMilestoneIssues(pid interface{}, milestone int, opt *GetMilestoneIssuesOptions, options ...OptionFunc) ([]*Issue, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/milestones/%d/issues", url.QueryEscape(project), milestone) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/namespaces.go b/vendor/github.com/xanzy/go-gitlab/namespaces.go index b849cbf..d4b5e45 100644 --- a/vendor/github.com/xanzy/go-gitlab/namespaces.go +++ b/vendor/github.com/xanzy/go-gitlab/namespaces.go @@ -48,8 +48,8 @@ type ListNamespacesOptions struct { // ListNamespaces gets a list of projects accessible by the authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces -func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions) ([]*Namespace, *Response, error) { - req, err := s.client.NewRequest("GET", "namespaces", opt) +func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions, options ...OptionFunc) ([]*Namespace, *Response, error) { + req, err := s.client.NewRequest("GET", "namespaces", opt, options) if err != nil { return nil, nil, err } @@ -68,13 +68,13 @@ func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions) ([]*Names // // GitLab API docs: // https://docs.gitlab.com/ce/api/namespaces.html#search-for-namespace -func (s *NamespacesService) SearchNamespace(query string) ([]*Namespace, *Response, error) { +func (s *NamespacesService) SearchNamespace(query string, options ...OptionFunc) ([]*Namespace, *Response, error) { var q struct { Search string `url:"search,omitempty" json:"search,omitempty"` } q.Search = query - req, err := s.client.NewRequest("GET", "namespaces", &q) + req, err := s.client.NewRequest("GET", "namespaces", &q, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/notes.go b/vendor/github.com/xanzy/go-gitlab/notes.go index 04e8a64..c1836c2 100644 --- a/vendor/github.com/xanzy/go-gitlab/notes.go +++ b/vendor/github.com/xanzy/go-gitlab/notes.go @@ -68,17 +68,14 @@ type ListIssueNotesOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#list-project-issue-notes -func (s *NotesService) ListIssueNotes( - pid interface{}, - issue int, - opt *ListIssueNotesOptions) ([]*Note, *Response, error) { +func (s *NotesService) ListIssueNotes(pid interface{}, issue int, opt *ListIssueNotesOptions, options ...OptionFunc) ([]*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/notes", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -96,17 +93,14 @@ func (s *NotesService) ListIssueNotes( // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#get-single-issue-note -func (s *NotesService) GetIssueNote( - pid interface{}, - issue int, - note int) (*Note, *Response, error) { +func (s *NotesService) GetIssueNote(pid interface{}, issue int, note int, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", url.QueryEscape(project), issue, note) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -133,17 +127,14 @@ type CreateIssueNoteOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#create-new-issue-note -func (s *NotesService) CreateIssueNote( - pid interface{}, - issue int, - opt *CreateIssueNoteOptions) (*Note, *Response, error) { +func (s *NotesService) CreateIssueNote(pid interface{}, issue int, opt *CreateIssueNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/notes", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -169,18 +160,14 @@ type UpdateIssueNoteOptions struct { // UpdateIssueNote modifies existing note of an issue. // // https://docs.gitlab.com/ce/api/notes.html#modify-existing-issue-note -func (s *NotesService) UpdateIssueNote( - pid interface{}, - issue int, - note int, - opt *UpdateIssueNoteOptions) (*Note, *Response, error) { +func (s *NotesService) UpdateIssueNote(pid interface{}, issue int, note int, opt *UpdateIssueNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", url.QueryEscape(project), issue, note) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -199,14 +186,14 @@ func (s *NotesService) UpdateIssueNote( // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#list-all-snippet-notes -func (s *NotesService) ListSnippetNotes(pid interface{}, snippet int) ([]*Note, *Response, error) { +func (s *NotesService) ListSnippetNotes(pid interface{}, snippet int, options ...OptionFunc) ([]*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d/notes", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -224,17 +211,14 @@ func (s *NotesService) ListSnippetNotes(pid interface{}, snippet int) ([]*Note, // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#get-single-snippet-note -func (s *NotesService) GetSnippetNote( - pid interface{}, - snippet int, - note int) (*Note, *Response, error) { +func (s *NotesService) GetSnippetNote(pid interface{}, snippet int, note int, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", url.QueryEscape(project), snippet, note) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -262,17 +246,14 @@ type CreateSnippetNoteOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#create-new-snippet-note -func (s *NotesService) CreateSnippetNote( - pid interface{}, - snippet int, - opt *CreateSnippetNoteOptions) (*Note, *Response, error) { +func (s *NotesService) CreateSnippetNote(pid interface{}, snippet int, opt *CreateSnippetNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d/notes", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -298,18 +279,14 @@ type UpdateSnippetNoteOptions struct { // UpdateSnippetNote modifies existing note of a snippet. // // https://docs.gitlab.com/ce/api/notes.html#modify-existing-snippet-note -func (s *NotesService) UpdateSnippetNote( - pid interface{}, - snippet int, - note int, - opt *UpdateSnippetNoteOptions) (*Note, *Response, error) { +func (s *NotesService) UpdateSnippetNote(pid interface{}, snippet int, note int, opt *UpdateSnippetNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", url.QueryEscape(project), snippet, note) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -327,16 +304,14 @@ func (s *NotesService) UpdateSnippetNote( // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#list-all-merge-request-notes -func (s *NotesService) ListMergeRequestNotes( - pid interface{}, - mergeRequest int) ([]*Note, *Response, error) { +func (s *NotesService) ListMergeRequestNotes(pid interface{}, mergeRequest int, options ...OptionFunc) ([]*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -354,17 +329,14 @@ func (s *NotesService) ListMergeRequestNotes( // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#get-single-merge-request-note -func (s *NotesService) GetMergeRequestNote( - pid interface{}, - mergeRequest int, - note int) (*Note, *Response, error) { +func (s *NotesService) GetMergeRequestNote(pid interface{}, mergeRequest int, note int, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/merge_requests/%d/notes/%d", url.QueryEscape(project), mergeRequest, note) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -391,17 +363,14 @@ type CreateMergeRequestNoteOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/notes.html#create-new-merge-request-note -func (s *NotesService) CreateMergeRequestNote( - pid interface{}, - mergeRequest int, - opt *CreateMergeRequestNoteOptions) (*Note, *Response, error) { +func (s *NotesService) CreateMergeRequestNote(pid interface{}, mergeRequest int, opt *CreateMergeRequestNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", url.QueryEscape(project), mergeRequest) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -427,19 +396,14 @@ type UpdateMergeRequestNoteOptions struct { // UpdateMergeRequestNote modifies existing note of a merge request. // // https://docs.gitlab.com/ce/api/notes.html#modify-existing-merge-request-note -func (s *NotesService) UpdateMergeRequestNote( - pid interface{}, - mergeRequest int, - note int, - opt *UpdateMergeRequestNoteOptions) (*Note, *Response, error) { +func (s *NotesService) UpdateMergeRequestNote(pid interface{}, mergeRequest int, note int, opt *UpdateMergeRequestNoteOptions, options ...OptionFunc) (*Note, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf( "projects/%s/merge_requests/%d/notes/%d", url.QueryEscape(project), mergeRequest, note) - - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/notifications.go b/vendor/github.com/xanzy/go-gitlab/notifications.go new file mode 100644 index 0000000..04424c2 --- /dev/null +++ b/vendor/github.com/xanzy/go-gitlab/notifications.go @@ -0,0 +1,214 @@ +package gitlab + +import ( + "errors" + "fmt" + "net/url" +) + +// NotificationSettingsService handles communication with the notification settings +// related methods of the GitLab API. +// +// GitLab API docs: https://docs.gitlab.com/ce/api/notification_settings.html +type NotificationSettingsService struct { + client *Client +} + +// NotificationSettings represents the Gitlab notification setting. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#notification-settings +type NotificationSettings struct { + Level NotificationLevelValue `json:"level"` + NotificationEmail string `json:"notification_email"` + Events *NotificationEvents `json:"events"` +} + +// NotificationEvents represents the avialable notification setting events. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#notification-settings +type NotificationEvents struct { + CloseIssue bool `json:"close_issue"` + CloseMergeRequest bool `json:"close_merge_request"` + FailedPipeline bool `json:"failed_pipeline"` + MergeMergeRequest bool `json:"merge_merge_request"` + NewIssue bool `json:"new_issue"` + NewMergeRequest bool `json:"new_merge_request"` + NewNote bool `json:"new_note"` + ReassignIssue bool `json:"reassign_issue"` + ReassignMergeRequest bool `json:"reassign_merge_request"` + ReopenIssue bool `json:"reopen_issue"` + ReopenMergeRequest bool `json:"reopen_merge_request"` + SuccessPipeline bool `json:"success_pipeline"` +} + +func (ns NotificationSettings) String() string { + return Stringify(ns) +} + +// GetGlobalSettings returns current notification settings and email address. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#global-notification-settings +func (s *NotificationSettingsService) GetGlobalSettings(options ...OptionFunc) (*NotificationSettings, *Response, error) { + u := "notification_settings" + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} + +// NotificationSettingsOptions represents the available options that can be passed +// to the API when updating the notification settings. +type NotificationSettingsOptions struct { + Level *NotificationLevelValue `url:"level,omitempty" json:"level,omitempty"` + NotificationEmail *string `url:"notification_email,omitempty" json:"notification_email,omitempty"` + CloseIssue *bool `url:"close_issue,omitempty" json:"close_issue,omitempty"` + CloseMergeRequest *bool `url:"close_merge_request,omitempty" json:"close_merge_request,omitempty"` + FailedPipeline *bool `url:"failed_pipeline,omitempty" json:"failed_pipeline,omitempty"` + MergeMergeRequest *bool `url:"merge_merge_request,omitempty" json:"merge_merge_request,omitempty"` + NewIssue *bool `url:"new_issue,omitempty" json:"new_issue,omitempty"` + NewMergeRequest *bool `url:"new_merge_request,omitempty" json:"new_merge_request,omitempty"` + NewNote *bool `url:"new_note,omitempty" json:"new_note,omitempty"` + ReassignIssue *bool `url:"reassign_issue,omitempty" json:"reassign_issue,omitempty"` + ReassignMergeRequest *bool `url:"reassign_merge_request,omitempty" json:"reassign_merge_request,omitempty"` + ReopenIssue *bool `url:"reopen_issue,omitempty" json:"reopen_issue,omitempty"` + ReopenMergeRequest *bool `url:"reopen_merge_request,omitempty" json:"reopen_merge_request,omitempty"` + SuccessPipeline *bool `url:"success_pipeline,omitempty" json:"success_pipeline,omitempty"` +} + +// UpdateGlobalSettings updates current notification settings and email address. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#update-global-notification-settings +func (s *NotificationSettingsService) UpdateGlobalSettings(opt *NotificationSettingsOptions, options ...OptionFunc) (*NotificationSettings, *Response, error) { + if opt.Level != nil && *opt.Level == GlobalNotificationLevel { + return nil, nil, errors.New( + "notification level 'global' is not valid for global notification settings") + } + + u := "notification_settings" + + req, err := s.client.NewRequest("PUT", u, opt, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} + +// GetSettingsForGroup returns current group notification settings. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#group-project-level-notification-settings +func (s *NotificationSettingsService) GetSettingsForGroup(gid interface{}, options ...OptionFunc) (*NotificationSettings, *Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/notification_settings", url.QueryEscape(group)) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} + +// GetSettingsForProject returns current project notification settings. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#group-project-level-notification-settings +func (s *NotificationSettingsService) GetSettingsForProject(pid interface{}, options ...OptionFunc) (*NotificationSettings, *Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("projects/%s/notification_settings", url.QueryEscape(project)) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} + +// UpdateSettingsForGroup updates current group notification settings. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#update-group-project-level-notification-settings +func (s *NotificationSettingsService) UpdateSettingsForGroup(gid interface{}, opt *NotificationSettingsOptions, options ...OptionFunc) (*NotificationSettings, *Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/notification_settings", url.QueryEscape(group)) + + req, err := s.client.NewRequest("PUT", u, opt, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} + +// UpdateSettingsForProject updates current project notification settings. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/notification_settings.html#update-group-project-level-notification-settings +func (s *NotificationSettingsService) UpdateSettingsForProject(pid interface{}, opt *NotificationSettingsOptions, options ...OptionFunc) (*NotificationSettings, *Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("projects/%s/notification_settings", url.QueryEscape(project)) + + req, err := s.client.NewRequest("PUT", u, opt, options) + if err != nil { + return nil, nil, err + } + + ns := new(NotificationSettings) + resp, err := s.client.Do(req, ns) + if err != nil { + return nil, resp, err + } + + return ns, resp, err +} diff --git a/vendor/github.com/xanzy/go-gitlab/pipelines.go b/vendor/github.com/xanzy/go-gitlab/pipelines.go index 45ac968..4ade3fc 100644 --- a/vendor/github.com/xanzy/go-gitlab/pipelines.go +++ b/vendor/github.com/xanzy/go-gitlab/pipelines.go @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // + package gitlab import ( @@ -46,7 +47,7 @@ type Pipeline struct { ID int `json:"id"` State string `json:"state"` AvatarURL string `json:"avatar_url"` - WebUrl string `json:"web_url"` + WebURL string `json:"web_url"` } UpdatedAt *time.Time `json:"updated_at"` CreatedAt *time.Time `json:"created_at"` @@ -64,14 +65,14 @@ func (i Pipeline) String() string { // ListProjectPipelines gets a list of project piplines. // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines -func (s *PipelinesService) ListProjectPipelines(pid interface{}) ([]*Pipeline, *Response, error) { +func (s *PipelinesService) ListProjectPipelines(pid interface{}, options ...OptionFunc) ([]*Pipeline, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/pipelines", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -87,14 +88,14 @@ func (s *PipelinesService) ListProjectPipelines(pid interface{}) ([]*Pipeline, * // GetPipeline gets a single project pipeline. // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#get-a-single-pipeline -func (s *PipelinesService) GetPipeline(pid interface{}, pipeline int) (*Pipeline, *Response, error) { +func (s *PipelinesService) GetPipeline(pid interface{}, pipeline int, options ...OptionFunc) (*Pipeline, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/pipelines/%d", url.QueryEscape(project), pipeline) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -118,14 +119,14 @@ type CreatePipelineOptions struct { // CreatePipeline creates a new project pipeline. // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#create-a-new-pipeline -func (s *PipelinesService) CreatePipeline(pid interface{}, opt *CreatePipelineOptions) (*Pipeline, *Response, error) { +func (s *PipelinesService) CreatePipeline(pid interface{}, opt *CreatePipelineOptions, options ...OptionFunc) (*Pipeline, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/pipeline", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -143,14 +144,14 @@ func (s *PipelinesService) CreatePipeline(pid interface{}, opt *CreatePipelineOp // // GitLab API docs: // https://docs.gitlab.com/ce/api/pipelines.html#retry-failed-builds-in-a-pipeline -func (s *PipelinesService) RetryPipelineBuild(pid interface{}, pipelineID int) (*Pipeline, *Response, error) { +func (s *PipelinesService) RetryPipelineBuild(pid interface{}, pipelineID int, options ...OptionFunc) (*Pipeline, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/pipelines/%d/retry", project, pipelineID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -168,14 +169,14 @@ func (s *PipelinesService) RetryPipelineBuild(pid interface{}, pipelineID int) ( // // GitLab API docs: //https://docs.gitlab.com/ce/api/pipelines.html#cancel-a-pipelines-builds -func (s *PipelinesService) CancelPipelineBuild(pid interface{}, pipelineID int) (*Pipeline, *Response, error) { +func (s *PipelinesService) CancelPipelineBuild(pid interface{}, pipelineID int, options ...OptionFunc) (*Pipeline, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", project, pipelineID) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/project_snippets.go b/vendor/github.com/xanzy/go-gitlab/project_snippets.go index 6716b5c..65dab67 100644 --- a/vendor/github.com/xanzy/go-gitlab/project_snippets.go +++ b/vendor/github.com/xanzy/go-gitlab/project_snippets.go @@ -65,16 +65,14 @@ type ListSnippetsOptions struct { // ListSnippets gets a list of project snippets. // // GitLab API docs: https://docs.gitlab.com/ce/api/project_snippets.html#list-snippets -func (s *ProjectSnippetsService) ListSnippets( - pid interface{}, - opt *ListSnippetsOptions) ([]*Snippet, *Response, error) { +func (s *ProjectSnippetsService) ListSnippets(pid interface{}, opt *ListSnippetsOptions, options ...OptionFunc) ([]*Snippet, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -92,16 +90,14 @@ func (s *ProjectSnippetsService) ListSnippets( // // GitLab API docs: // https://docs.gitlab.com/ce/api/project_snippets.html#single-snippet -func (s *ProjectSnippetsService) GetSnippet( - pid interface{}, - snippet int) (*Snippet, *Response, error) { +func (s *ProjectSnippetsService) GetSnippet(pid interface{}, snippet int, options ...OptionFunc) (*Snippet, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -131,16 +127,14 @@ type CreateSnippetOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/project_snippets.html#create-new-snippet -func (s *ProjectSnippetsService) CreateSnippet( - pid interface{}, - opt *CreateSnippetOptions) (*Snippet, *Response, error) { +func (s *ProjectSnippetsService) CreateSnippet(pid interface{}, opt *CreateSnippetOptions, options ...OptionFunc) (*Snippet, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -170,17 +164,14 @@ type UpdateSnippetOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/project_snippets.html#update-snippet -func (s *ProjectSnippetsService) UpdateSnippet( - pid interface{}, - snippet int, - opt *UpdateSnippetOptions) (*Snippet, *Response, error) { +func (s *ProjectSnippetsService) UpdateSnippet(pid interface{}, snippet int, opt *UpdateSnippetOptions, options ...OptionFunc) (*Snippet, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -200,14 +191,14 @@ func (s *ProjectSnippetsService) UpdateSnippet( // // GitLab API docs: // https://docs.gitlab.com/ce/api/project_snippets.html#delete-snippet -func (s *ProjectSnippetsService) DeleteSnippet(pid interface{}, snippet int) (*Response, error) { +func (s *ProjectSnippetsService) DeleteSnippet(pid interface{}, snippet int, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/snippets/%d", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -219,16 +210,14 @@ func (s *ProjectSnippetsService) DeleteSnippet(pid interface{}, snippet int) (*R // // GitLab API docs: // https://docs.gitlab.com/ce/api/project_snippets.html#snippet-content -func (s *ProjectSnippetsService) SnippetContent( - pid interface{}, - snippet int) ([]byte, *Response, error) { +func (s *ProjectSnippetsService) SnippetContent(pid interface{}, snippet int, options ...OptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/snippets/%d/raw", url.QueryEscape(project), snippet) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/projects.go b/vendor/github.com/xanzy/go-gitlab/projects.go index c0a64d8..86cd0d3 100644 --- a/vendor/github.com/xanzy/go-gitlab/projects.go +++ b/vendor/github.com/xanzy/go-gitlab/projects.go @@ -146,8 +146,8 @@ type ListProjectsOptions struct { // ListProjects gets a list of projects accessible by the authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-projects -func (s *ProjectsService) ListProjects(opt *ListProjectsOptions) ([]*Project, *Response, error) { - req, err := s.client.NewRequest("GET", "projects", opt) +func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { + req, err := s.client.NewRequest("GET", "projects", opt, options) if err != nil { return nil, nil, err } @@ -166,9 +166,8 @@ func (s *ProjectsService) ListProjects(opt *ListProjectsOptions) ([]*Project, *R // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#list-owned-projects -func (s *ProjectsService) ListOwnedProjects( - opt *ListProjectsOptions) ([]*Project, *Response, error) { - req, err := s.client.NewRequest("GET", "projects/owned", opt) +func (s *ProjectsService) ListOwnedProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { + req, err := s.client.NewRequest("GET", "projects/owned", opt, options) if err != nil { return nil, nil, err } @@ -187,9 +186,8 @@ func (s *ProjectsService) ListOwnedProjects( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#list-starred-projects -func (s *ProjectsService) ListStarredProjects( - opt *ListProjectsOptions) ([]*Project, *Response, error) { - req, err := s.client.NewRequest("GET", "projects/starred", opt) +func (s *ProjectsService) ListStarredProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { + req, err := s.client.NewRequest("GET", "projects/starred", opt, options) if err != nil { return nil, nil, err } @@ -207,8 +205,8 @@ func (s *ProjectsService) ListStarredProjects( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#list-all-projects -func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions) ([]*Project, *Response, error) { - req, err := s.client.NewRequest("GET", "projects/all", opt) +func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { + req, err := s.client.NewRequest("GET", "projects/all", opt, options) if err != nil { return nil, nil, err } @@ -227,14 +225,14 @@ func (s *ProjectsService) ListAllProjects(opt *ListProjectsOptions) ([]*Project, // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#get-single-project -func (s *ProjectsService) GetProject(pid interface{}) (*Project, *Response, error) { +func (s *ProjectsService) GetProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -263,12 +261,10 @@ type SearchProjectsOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#search-for-projects-by-name -func (s *ProjectsService) SearchProjects( - query string, - opt *SearchProjectsOptions) ([]*Project, *Response, error) { +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) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -324,16 +320,14 @@ type GetProjectEventsOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#get-project-events -func (s *ProjectsService) GetProjectEvents( - pid interface{}, - opt *GetProjectEventsOptions) ([]*ProjectEvent, *Response, error) { +func (s *ProjectsService) GetProjectEvents(pid interface{}, opt *GetProjectEventsOptions, options ...OptionFunc) ([]*ProjectEvent, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/events", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -374,9 +368,8 @@ type CreateProjectOptions struct { // 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) (*Project, *Response, error) { - req, err := s.client.NewRequest("POST", "projects", opt) +func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...OptionFunc) (*Project, *Response, error) { + req, err := s.client.NewRequest("POST", "projects", opt, options) if err != nil { return nil, nil, err } @@ -413,12 +406,10 @@ type CreateProjectForUserOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#create-project-for-user -func (s *ProjectsService) CreateProjectForUser( - user int, - opt *CreateProjectForUserOptions) (*Project, *Response, error) { +func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUserOptions, options ...OptionFunc) (*Project, *Response, error) { u := fmt.Sprintf("projects/user/%d", user) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -461,16 +452,14 @@ type EditProjectOptions struct { // EditProject updates an existing project. // // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project -func (s *ProjectsService) EditProject( - pid interface{}, - opt *EditProjectOptions) (*Project, *Response, error) { +func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, options ...OptionFunc) (*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -488,14 +477,14 @@ func (s *ProjectsService) EditProject( // user. // // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#fork-project -func (s *ProjectsService) ForkProject(pid interface{}) (*Project, *Response, error) { +func (s *ProjectsService) ForkProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/fork/%s", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -513,14 +502,14 @@ func (s *ProjectsService) ForkProject(pid interface{}) (*Project, *Response, err // (issues, merge requests etc.) // // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#remove-project -func (s *ProjectsService) DeleteProject(pid interface{}) (*Response, error) { +func (s *ProjectsService) DeleteProject(pid interface{}, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -556,16 +545,14 @@ type ListProjectMembersOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#list-project-team-members -func (s *ProjectsService) ListProjectMembers( - pid interface{}, - opt *ListProjectMembersOptions) ([]*ProjectMember, *Response, error) { +func (s *ProjectsService) ListProjectMembers(pid interface{}, opt *ListProjectMembersOptions, options ...OptionFunc) ([]*ProjectMember, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/members", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -583,16 +570,14 @@ func (s *ProjectsService) ListProjectMembers( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#get-project-team-member -func (s *ProjectsService) GetProjectMember( - pid interface{}, - user int) (*ProjectMember, *Response, error) { +func (s *ProjectsService) GetProjectMember(pid interface{}, user int, options ...OptionFunc) (*ProjectMember, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/members/%d", url.QueryEscape(project), user) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -622,16 +607,14 @@ type AddProjectMemberOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#add-project-team-member -func (s *ProjectsService) AddProjectMember( - pid interface{}, - opt *AddProjectMemberOptions) (*ProjectMember, *Response, error) { +func (s *ProjectsService) AddProjectMember(pid interface{}, opt *AddProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/members", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -657,17 +640,14 @@ type EditProjectMemberOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#edit-project-team-member -func (s *ProjectsService) EditProjectMember( - pid interface{}, - user int, - opt *EditProjectMemberOptions) (*ProjectMember, *Response, error) { +func (s *ProjectsService) EditProjectMember(pid interface{}, user int, opt *EditProjectMemberOptions, options ...OptionFunc) (*ProjectMember, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/members/%d", url.QueryEscape(project), user) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -685,14 +665,14 @@ func (s *ProjectsService) EditProjectMember( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#remove-project-team-member -func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int) (*Response, error) { +func (s *ProjectsService) DeleteProjectMember(pid interface{}, user int, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/members/%d", url.QueryEscape(project), user) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -731,16 +711,14 @@ type ListProjectHooksOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#list-project-hooks -func (s *ProjectsService) ListProjectHooks( - pid interface{}, - opt *ListProjectHooksOptions) ([]*ProjectHook, *Response, error) { +func (s *ProjectsService) ListProjectHooks(pid interface{}, opt *ListProjectHooksOptions, options ...OptionFunc) ([]*ProjectHook, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/hooks", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -758,16 +736,14 @@ func (s *ProjectsService) ListProjectHooks( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#get-project-hook -func (s *ProjectsService) GetProjectHook( - pid interface{}, - hook int) (*ProjectHook, *Response, error) { +func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...OptionFunc) (*ProjectHook, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/hooks/%d", url.QueryEscape(project), hook) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -803,16 +779,14 @@ type AddProjectHookOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#add-project-hook -func (s *ProjectsService) AddProjectHook( - pid interface{}, - opt *AddProjectHookOptions) (*ProjectHook, *Response, error) { +func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/hooks", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -848,17 +822,14 @@ type EditProjectHookOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#edit-project-hook -func (s *ProjectsService) EditProjectHook( - pid interface{}, - hook int, - opt *EditProjectHookOptions) (*ProjectHook, *Response, error) { +func (s *ProjectsService) EditProjectHook(pid interface{}, hook int, opt *EditProjectHookOptions, options ...OptionFunc) (*ProjectHook, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/hooks/%d", url.QueryEscape(project), hook) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -877,14 +848,14 @@ func (s *ProjectsService) EditProjectHook( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#delete-project-hook -func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int) (*Response, error) { +func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/hooks/%d", url.QueryEscape(project), hook) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -909,12 +880,10 @@ type ProjectForkRelation struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#create-a-forked-fromto-relation-between-existing-projects. -func (s *ProjectsService) CreateProjectForkRelation( - pid int, - fork int) (*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) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -932,10 +901,10 @@ func (s *ProjectsService) CreateProjectForkRelation( // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#delete-an-existing-forked-from-relationship -func (s *ProjectsService) DeleteProjectForkRelation(pid int) (*Response, error) { +func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("projects/%d/fork", pid) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -948,14 +917,14 @@ func (s *ProjectsService) DeleteProjectForkRelation(pid int) (*Response, error) // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#archive-a-project -func (s *ProjectsService) ArchiveProject(pid interface{}) (*Project, *Response, error) { +func (s *ProjectsService) ArchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/archive", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -974,14 +943,14 @@ func (s *ProjectsService) ArchiveProject(pid interface{}) (*Project, *Response, // // GitLab API docs: // https://docs.gitlab.com/ce/api/projects.html#unarchive-a-project -func (s *ProjectsService) UnarchiveProject(pid interface{}) (*Project, *Response, error) { +func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...OptionFunc) (*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/unarchive", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/repositories.go b/vendor/github.com/xanzy/go-gitlab/repositories.go index df2d10c..aa1052f 100644 --- a/vendor/github.com/xanzy/go-gitlab/repositories.go +++ b/vendor/github.com/xanzy/go-gitlab/repositories.go @@ -57,16 +57,14 @@ type ListTreeOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repositories.html#list-repository-tree -func (s *RepositoriesService) ListTree( - pid interface{}, - opt *ListTreeOptions) ([]*TreeNode, *Response, error) { +func (s *RepositoriesService) ListTree(pid interface{}, opt *ListTreeOptions, options ...OptionFunc) ([]*TreeNode, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/tree", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -92,17 +90,14 @@ type RawFileContentOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repositories.html#raw-file-content -func (s *RepositoriesService) RawFileContent( - pid interface{}, - sha string, - opt *RawFileContentOptions) ([]byte, *Response, error) { +func (s *RepositoriesService) RawFileContent(pid interface{}, sha string, opt *RawFileContentOptions, options ...OptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/blobs/%s", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -120,16 +115,14 @@ func (s *RepositoriesService) RawFileContent( // // GitLab API docs: // https://docs.gitlab.com/ce/api/repositories.html#raw-blob-content -func (s *RepositoriesService) RawBlobContent( - pid interface{}, - sha string) ([]byte, *Response, error) { +func (s *RepositoriesService) RawBlobContent(pid interface{}, sha string, options ...OptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/raw_blobs/%s", url.QueryEscape(project), sha) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -155,16 +148,14 @@ type ArchiveOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repositories.html#get-file-archive -func (s *RepositoriesService) Archive( - pid interface{}, - opt *ArchiveOptions) ([]byte, *Response, error) { +func (s *RepositoriesService) Archive(pid interface{}, opt *ArchiveOptions, options ...OptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/archive", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -207,16 +198,14 @@ type CompareOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repositories.html#compare-branches-tags-or-commits -func (s *RepositoriesService) Compare( - pid interface{}, - opt *CompareOptions) (*Compare, *Response, error) { +func (s *RepositoriesService) Compare(pid interface{}, opt *CompareOptions, options ...OptionFunc) (*Compare, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/compare", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -248,14 +237,14 @@ func (c Contributor) String() string { // Contributors gets the repository contributors list. // // GitLab API docs: https://docs.gitlab.com/ce/api/repositories.html#contributer -func (s *RepositoriesService) Contributors(pid interface{}) ([]*Contributor, *Response, error) { +func (s *RepositoriesService) Contributors(pid interface{}, options ...OptionFunc) ([]*Contributor, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/contributors", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/repository_files.go b/vendor/github.com/xanzy/go-gitlab/repository_files.go index dbd77f4..21e5f65 100644 --- a/vendor/github.com/xanzy/go-gitlab/repository_files.go +++ b/vendor/github.com/xanzy/go-gitlab/repository_files.go @@ -61,16 +61,14 @@ type GetFileOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repository_files.html#get-file-from-respository -func (s *RepositoryFilesService) GetFile( - pid interface{}, - opt *GetFileOptions) (*File, *Response, error) { +func (s *RepositoryFilesService) GetFile(pid interface{}, opt *GetFileOptions, options ...OptionFunc) (*File, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/files", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, opt) + req, err := s.client.NewRequest("GET", u, opt, options) if err != nil { return nil, nil, err } @@ -114,16 +112,14 @@ type CreateFileOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repository_files.html#create-new-file-in-repository -func (s *RepositoryFilesService) CreateFile( - pid interface{}, - opt *CreateFileOptions) (*FileInfo, *Response, error) { +func (s *RepositoryFilesService) CreateFile(pid interface{}, opt *CreateFileOptions, options ...OptionFunc) (*FileInfo, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/files", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -155,16 +151,14 @@ type UpdateFileOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repository_files.html#update-existing-file-in-repository -func (s *RepositoryFilesService) UpdateFile( - pid interface{}, - opt *UpdateFileOptions) (*FileInfo, *Response, error) { +func (s *RepositoryFilesService) UpdateFile(pid interface{}, opt *UpdateFileOptions, options ...OptionFunc) (*FileInfo, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/files", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -194,16 +188,14 @@ type DeleteFileOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/repository_files.html#delete-existing-file-in-repository -func (s *RepositoryFilesService) DeleteFile( - pid interface{}, - opt *DeleteFileOptions) (*FileInfo, *Response, error) { +func (s *RepositoryFilesService) DeleteFile(pid interface{}, opt *DeleteFileOptions, options ...OptionFunc) (*FileInfo, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/files", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, opt) + req, err := s.client.NewRequest("DELETE", u, opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/services.go b/vendor/github.com/xanzy/go-gitlab/services.go index a2a80ac..dbcdf84 100644 --- a/vendor/github.com/xanzy/go-gitlab/services.go +++ b/vendor/github.com/xanzy/go-gitlab/services.go @@ -60,16 +60,14 @@ type SetGitLabCIServiceOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#edit-gitlab-ci-service -func (s *ServicesService) SetGitLabCIService( - pid interface{}, - opt *SetGitLabCIServiceOptions) (*Response, error) { +func (s *ServicesService) SetGitLabCIService(pid interface{}, opt *SetGitLabCIServiceOptions, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/gitlab-ci", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, err } @@ -81,14 +79,14 @@ func (s *ServicesService) SetGitLabCIService( // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#delete-gitlab-ci-service -func (s *ServicesService) DeleteGitLabCIService(pid interface{}) (*Response, error) { +func (s *ServicesService) DeleteGitLabCIService(pid interface{}, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/gitlab-ci", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -110,16 +108,14 @@ type SetHipChatServiceOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#edit-hipchat-service -func (s *ServicesService) SetHipChatService( - pid interface{}, - opt *SetHipChatServiceOptions) (*Response, error) { +func (s *ServicesService) SetHipChatService(pid interface{}, opt *SetHipChatServiceOptions, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/hipchat", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, err } @@ -131,14 +127,14 @@ func (s *ServicesService) SetHipChatService( // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#delete-hipchat-service -func (s *ServicesService) DeleteHipChatService(pid interface{}) (*Response, error) { +func (s *ServicesService) DeleteHipChatService(pid interface{}, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/hipchat", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -161,16 +157,14 @@ type SetDroneCIServiceOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#createedit-drone-ci-service -func (s *ServicesService) SetDroneCIService( - pid interface{}, - opt *SetDroneCIServiceOptions) (*Response, error) { +func (s *ServicesService) SetDroneCIService(pid interface{}, opt *SetDroneCIServiceOptions, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/drone-ci", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, err } @@ -182,14 +176,14 @@ func (s *ServicesService) SetDroneCIService( // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#delete-drone-ci-service -func (s *ServicesService) DeleteDroneCIService(pid interface{}) (*Response, error) { +func (s *ServicesService) DeleteDroneCIService(pid interface{}, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/drone-ci", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -214,14 +208,14 @@ type DroneCIService struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#get-drone-ci-service-settings -func (s *ServicesService) GetDroneCIService(pid interface{}) (*DroneCIService, *Response, error) { +func (s *ServicesService) GetDroneCIService(pid interface{}, options ...OptionFunc) (*DroneCIService, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/services/drone-ci", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -250,16 +244,14 @@ type SetSlackServiceOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#edit-slack-service -func (s *ServicesService) SetSlackService( - pid interface{}, - opt *SetSlackServiceOptions) (*Response, error) { +func (s *ServicesService) SetSlackService(pid interface{}, opt *SetSlackServiceOptions, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/slack", url.QueryEscape(project)) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, err } @@ -271,14 +263,14 @@ func (s *ServicesService) SetSlackService( // // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#delete-slack-service -func (s *ServicesService) DeleteSlackService(pid interface{}) (*Response, error) { +func (s *ServicesService) DeleteSlackService(pid interface{}, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/services/slack", url.QueryEscape(project)) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/session.go b/vendor/github.com/xanzy/go-gitlab/session.go index efe0169..571483c 100644 --- a/vendor/github.com/xanzy/go-gitlab/session.go +++ b/vendor/github.com/xanzy/go-gitlab/session.go @@ -62,8 +62,8 @@ type GetSessionOptions struct { // GetSession logs in to get private token. // // GitLab API docs: https://docs.gitlab.com/ce/api/session.html#session -func (s *SessionService) GetSession(opt *GetSessionOptions) (*Session, *Response, error) { - req, err := s.client.NewRequest("POST", "session", opt) +func (s *SessionService) GetSession(opt *GetSessionOptions, options ...OptionFunc) (*Session, *Response, error) { + req, err := s.client.NewRequest("POST", "session", opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/settings.go b/vendor/github.com/xanzy/go-gitlab/settings.go index cbb5523..41e9c9d 100644 --- a/vendor/github.com/xanzy/go-gitlab/settings.go +++ b/vendor/github.com/xanzy/go-gitlab/settings.go @@ -59,8 +59,8 @@ func (s Settings) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/settings.html#get-current-application.settings -func (s *SettingsService) GetSettings() (*Settings, *Response, error) { - req, err := s.client.NewRequest("GET", "application/settings", nil) +func (s *SettingsService) GetSettings(options ...OptionFunc) (*Settings, *Response, error) { + req, err := s.client.NewRequest("GET", "application/settings", nil, options) if err != nil { return nil, nil, err } @@ -101,8 +101,8 @@ type UpdateSettingsOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/settings.html#change-application.settings -func (s *SettingsService) UpdateSettings(opt *UpdateSettingsOptions) (*Settings, *Response, error) { - req, err := s.client.NewRequest("PUT", "application/settings", opt) +func (s *SettingsService) UpdateSettings(opt *UpdateSettingsOptions, options ...OptionFunc) (*Settings, *Response, error) { + req, err := s.client.NewRequest("PUT", "application/settings", opt, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/system_hooks.go b/vendor/github.com/xanzy/go-gitlab/system_hooks.go index 48e052a..20277a9 100644 --- a/vendor/github.com/xanzy/go-gitlab/system_hooks.go +++ b/vendor/github.com/xanzy/go-gitlab/system_hooks.go @@ -46,8 +46,8 @@ func (h Hook) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/system_hooks.html#list-system-hooks -func (s *SystemHooksService) ListHooks() ([]*Hook, *Response, error) { - req, err := s.client.NewRequest("GET", "hooks", nil) +func (s *SystemHooksService) ListHooks(options ...OptionFunc) ([]*Hook, *Response, error) { + req, err := s.client.NewRequest("GET", "hooks", nil, options) if err != nil { return nil, nil, err } @@ -73,8 +73,8 @@ 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) (*Hook, *Response, error) { - req, err := s.client.NewRequest("POST", "hooks", opt) +func (s *SystemHooksService) AddHook(opt *AddHookOptions, options ...OptionFunc) (*Hook, *Response, error) { + req, err := s.client.NewRequest("POST", "hooks", opt, options) if err != nil { return nil, nil, err } @@ -108,10 +108,10 @@ func (h HookEvent) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/system_hooks.html#test-system-hook -func (s *SystemHooksService) TestHook(hook int) (*HookEvent, *Response, error) { +func (s *SystemHooksService) TestHook(hook int, options ...OptionFunc) (*HookEvent, *Response, error) { u := fmt.Sprintf("hooks/%d", hook) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -131,10 +131,10 @@ func (s *SystemHooksService) TestHook(hook int) (*HookEvent, *Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/system_hooks.html#delete-system-hook -func (s *SystemHooksService) DeleteHook(hook int) (*Response, error) { +func (s *SystemHooksService) DeleteHook(hook int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("hooks/%d", hook) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/tags.go b/vendor/github.com/xanzy/go-gitlab/tags.go index 759cd7a..196f6d4 100644 --- a/vendor/github.com/xanzy/go-gitlab/tags.go +++ b/vendor/github.com/xanzy/go-gitlab/tags.go @@ -47,14 +47,14 @@ func (r Tag) String() string { // // GitLab API docs: // https://docs.gitlab.com/ce/api/tags.html#list-project-repository-tags -func (s *TagsService) ListTags(pid interface{}) ([]*Tag, *Response, error) { +func (s *TagsService) ListTags(pid interface{}, options ...OptionFunc) ([]*Tag, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/tags", url.QueryEscape(project)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -73,14 +73,14 @@ func (s *TagsService) ListTags(pid interface{}) ([]*Tag, *Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/tags.html#get-a-single-repository-tag -func (s *TagsService) GetTag(pid interface{}, tag string) (*Tag, *Response, error) { +func (s *TagsService) GetTag(pid interface{}, tag string, options ...OptionFunc) (*Tag, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/tags/%s", url.QueryEscape(project), tag) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -108,14 +108,14 @@ type CreateTagOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/tags.html#create-a-new-tag -func (s *TagsService) CreateTag(pid interface{}, opt *CreateTagOptions) (*Tag, *Response, error) { +func (s *TagsService) CreateTag(pid interface{}, opt *CreateTagOptions, options ...OptionFunc) (*Tag, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/repository/tags", url.QueryEscape(project)) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -133,14 +133,14 @@ func (s *TagsService) CreateTag(pid interface{}, opt *CreateTagOptions) (*Tag, * // // GitLab API docs: // https://docs.gitlab.com/ce/api/tags.html#delete-a-tag -func (s *TagsService) DeleteTag(pid interface{}, tag string) (*Response, error) { +func (s *TagsService) DeleteTag(pid interface{}, tag string, options ...OptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/repository/tags/%s", url.QueryEscape(project), tag) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/time_stats.go b/vendor/github.com/xanzy/go-gitlab/time_stats.go index a346389..c4a4ad4 100644 --- a/vendor/github.com/xanzy/go-gitlab/time_stats.go +++ b/vendor/github.com/xanzy/go-gitlab/time_stats.go @@ -41,17 +41,14 @@ type SetTimeEstimateOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/issues.html#set-a-time-estimate-for-an-issue -func (s *TimeStatsService) SetTimeEstimate( - pid interface{}, - issue int, - opt *SetTimeEstimateOptions) (*TimeStats, *Response, error) { +func (s *TimeStatsService) SetTimeEstimate(pid interface{}, issue int, opt *SetTimeEstimateOptions, options ...OptionFunc) (*TimeStats, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/time_estimate", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -69,16 +66,14 @@ func (s *TimeStatsService) SetTimeEstimate( // // GitLab API docs: // https://docs.gitlab.com/ce/api/issues.html#reset-the-time-estimate-for-an-issue -func (s *TimeStatsService) ResetTimeEstimate( - pid interface{}, - issue int) (*TimeStats, *Response, error) { +func (s *TimeStatsService) ResetTimeEstimate(pid interface{}, issue int, options ...OptionFunc) (*TimeStats, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/reset_time_estimate", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -104,17 +99,14 @@ type AddSpentTimeOptions struct { // // GitLab API docs: // https://docs.gitlab.com/ce/api/issues.html#add-spent-time-for-an-issue -func (s *TimeStatsService) AddSpentTime( - pid interface{}, - issue int, - opt *AddSpentTimeOptions) (*TimeStats, *Response, error) { +func (s *TimeStatsService) AddSpentTime(pid interface{}, issue int, opt *AddSpentTimeOptions, options ...OptionFunc) (*TimeStats, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/add_spent_time", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -132,16 +124,14 @@ func (s *TimeStatsService) AddSpentTime( // // GitLab API docs: // https://docs.gitlab.com/ce/api/issues.html#reset-spent-time-for-an-issue -func (s *TimeStatsService) ResetSpentTime( - pid interface{}, - issue int) (*TimeStats, *Response, error) { +func (s *TimeStatsService) ResetSpentTime(pid interface{}, issue int, options ...OptionFunc) (*TimeStats, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/reset_spent_time", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("POST", u, nil) + req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { return nil, nil, err } @@ -159,16 +149,14 @@ func (s *TimeStatsService) ResetSpentTime( // // GitLab API docs: // https://docs.gitlab.com/ce/api/issues.html#get-time-tracking-stats -func (s *TimeStatsService) GetTimeSpent( - pid interface{}, - issue int) (*TimeStats, *Response, error) { +func (s *TimeStatsService) GetTimeSpent(pid interface{}, issue int, options ...OptionFunc) (*TimeStats, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/issues/%d/time_stats", url.QueryEscape(project), issue) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/users.go b/vendor/github.com/xanzy/go-gitlab/users.go index 13ae2ae..ba955a8 100644 --- a/vendor/github.com/xanzy/go-gitlab/users.go +++ b/vendor/github.com/xanzy/go-gitlab/users.go @@ -79,8 +79,8 @@ type ListUsersOptions struct { // ListUsers gets a list of users. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-users -func (s *UsersService) ListUsers(opt *ListUsersOptions) ([]*User, *Response, error) { - req, err := s.client.NewRequest("GET", "users", opt) +func (s *UsersService) ListUsers(opt *ListUsersOptions, options ...OptionFunc) ([]*User, *Response, error) { + req, err := s.client.NewRequest("GET", "users", opt, options) if err != nil { return nil, nil, err } @@ -97,10 +97,10 @@ func (s *UsersService) ListUsers(opt *ListUsersOptions) ([]*User, *Response, err // GetUser gets a single user. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#single-user -func (s *UsersService) GetUser(user int) (*User, *Response, error) { +func (s *UsersService) GetUser(user int, options ...OptionFunc) (*User, *Response, error) { u := fmt.Sprintf("users/%d", user) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -138,8 +138,8 @@ type CreateUserOptions struct { // 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) (*User, *Response, error) { - req, err := s.client.NewRequest("POST", "users", opt) +func (s *UsersService) CreateUser(opt *CreateUserOptions, options ...OptionFunc) (*User, *Response, error) { + req, err := s.client.NewRequest("POST", "users", opt, options) if err != nil { return nil, nil, err } @@ -177,10 +177,10 @@ type ModifyUserOptions struct { // of a user. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#user-modification -func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions) (*User, *Response, error) { +func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions, options ...OptionFunc) (*User, *Response, error) { u := fmt.Sprintf("users/%d", user) - req, err := s.client.NewRequest("PUT", u, opt) + req, err := s.client.NewRequest("PUT", u, opt, options) if err != nil { return nil, nil, err } @@ -201,10 +201,10 @@ func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions) (*User, *Res // latter not. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#user-deletion -func (s *UsersService) DeleteUser(user int) (*Response, error) { +func (s *UsersService) DeleteUser(user int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("users/%d", user) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -215,8 +215,8 @@ func (s *UsersService) DeleteUser(user int) (*Response, error) { // CurrentUser gets currently authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#current-user -func (s *UsersService) CurrentUser() (*User, *Response, error) { - req, err := s.client.NewRequest("GET", "user", nil) +func (s *UsersService) CurrentUser(options ...OptionFunc) (*User, *Response, error) { + req, err := s.client.NewRequest("GET", "user", nil, options) if err != nil { return nil, nil, err } @@ -243,8 +243,8 @@ type SSHKey struct { // ListSSHKeys gets a list of currently authenticated user's SSH keys. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-ssh-keys -func (s *UsersService) ListSSHKeys() ([]*SSHKey, *Response, error) { - req, err := s.client.NewRequest("GET", "user/keys", nil) +func (s *UsersService) ListSSHKeys(options ...OptionFunc) ([]*SSHKey, *Response, error) { + req, err := s.client.NewRequest("GET", "user/keys", nil, options) if err != nil { return nil, nil, err } @@ -263,10 +263,10 @@ func (s *UsersService) ListSSHKeys() ([]*SSHKey, *Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#list-ssh-keys-for-user -func (s *UsersService) ListSSHKeysForUser(user int) ([]*SSHKey, *Response, error) { +func (s *UsersService) ListSSHKeysForUser(user int, options ...OptionFunc) ([]*SSHKey, *Response, error) { u := fmt.Sprintf("users/%d/keys", user) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -283,10 +283,10 @@ func (s *UsersService) ListSSHKeysForUser(user int) ([]*SSHKey, *Response, error // GetSSHKey gets a single key. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#single-ssh-key -func (s *UsersService) GetSSHKey(kid int) (*SSHKey, *Response, error) { +func (s *UsersService) GetSSHKey(kid int, options ...OptionFunc) (*SSHKey, *Response, error) { u := fmt.Sprintf("user/keys/%d", kid) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -311,8 +311,8 @@ type AddSSHKeyOptions struct { // AddSSHKey creates a new key owned by the currently authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-ssh-key -func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions) (*SSHKey, *Response, error) { - req, err := s.client.NewRequest("POST", "user/keys", opt) +func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions, options ...OptionFunc) (*SSHKey, *Response, error) { + req, err := s.client.NewRequest("POST", "user/keys", opt, options) if err != nil { return nil, nil, err } @@ -330,12 +330,10 @@ func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions) (*SSHKey, *Response, err // admin. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-ssh-key-for-user -func (s *UsersService) AddSSHKeyForUser( - user int, - opt *AddSSHKeyOptions) (*SSHKey, *Response, error) { +func (s *UsersService) AddSSHKeyForUser(user int, opt *AddSSHKeyOptions, options ...OptionFunc) (*SSHKey, *Response, error) { u := fmt.Sprintf("users/%d/keys", user) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -355,10 +353,10 @@ func (s *UsersService) AddSSHKeyForUser( // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#delete-ssh-key-for-current-owner -func (s *UsersService) DeleteSSHKey(kid int) (*Response, error) { +func (s *UsersService) DeleteSSHKey(kid int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("user/keys/%d", kid) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -371,10 +369,10 @@ func (s *UsersService) DeleteSSHKey(kid int) (*Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#delete-ssh-key-for-given-user -func (s *UsersService) DeleteSSHKeyForUser(user int, kid int) (*Response, error) { +func (s *UsersService) DeleteSSHKeyForUser(user int, kid int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("users/%d/keys/%d", user, kid) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -385,10 +383,10 @@ func (s *UsersService) DeleteSSHKeyForUser(user int, kid int) (*Response, error) // BlockUser blocks the specified user. Available only for admin. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#block-user -func (s *UsersService) BlockUser(user int) error { +func (s *UsersService) BlockUser(user int, options ...OptionFunc) error { u := fmt.Sprintf("users/%d/block", user) - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", u, nil, options) if err != nil { return err } @@ -413,10 +411,10 @@ func (s *UsersService) BlockUser(user int) error { // UnblockUser unblocks the specified user. Available only for admin. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#unblock-user -func (s *UsersService) UnblockUser(user int) error { +func (s *UsersService) UnblockUser(user int, options ...OptionFunc) error { u := fmt.Sprintf("users/%d/unblock", user) - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", u, nil, options) if err != nil { return err } @@ -449,8 +447,8 @@ type Email struct { // ListEmails gets a list of currently authenticated user's Emails. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-emails -func (s *UsersService) ListEmails() ([]*Email, *Response, error) { - req, err := s.client.NewRequest("GET", "user/emails", nil) +func (s *UsersService) ListEmails(options ...OptionFunc) ([]*Email, *Response, error) { + req, err := s.client.NewRequest("GET", "user/emails", nil, options) if err != nil { return nil, nil, err } @@ -469,10 +467,10 @@ func (s *UsersService) ListEmails() ([]*Email, *Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#list-emails-for-user -func (s *UsersService) ListEmailsForUser(uid int) ([]*Email, *Response, error) { +func (s *UsersService) ListEmailsForUser(uid int, options ...OptionFunc) ([]*Email, *Response, error) { u := fmt.Sprintf("users/%d/emails", uid) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -489,10 +487,10 @@ func (s *UsersService) ListEmailsForUser(uid int) ([]*Email, *Response, error) { // GetEmail gets a single email. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#single-email -func (s *UsersService) GetEmail(eid int) (*Email, *Response, error) { +func (s *UsersService) GetEmail(eid int, options ...OptionFunc) (*Email, *Response, error) { u := fmt.Sprintf("user/emails/%d", eid) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, nil, options) if err != nil { return nil, nil, err } @@ -516,8 +514,8 @@ type AddEmailOptions struct { // AddEmail creates a new email owned by the currently authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-email -func (s *UsersService) AddEmail(opt *AddEmailOptions) (*Email, *Response, error) { - req, err := s.client.NewRequest("POST", "user/emails", opt) +func (s *UsersService) AddEmail(opt *AddEmailOptions, options ...OptionFunc) (*Email, *Response, error) { + req, err := s.client.NewRequest("POST", "user/emails", opt, options) if err != nil { return nil, nil, err } @@ -535,12 +533,10 @@ func (s *UsersService) AddEmail(opt *AddEmailOptions) (*Email, *Response, error) // admin. // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-email-for-user -func (s *UsersService) AddEmailForUser( - uid int, - opt *AddEmailOptions) (*Email, *Response, error) { +func (s *UsersService) AddEmailForUser(uid int, opt *AddEmailOptions, options ...OptionFunc) (*Email, *Response, error) { u := fmt.Sprintf("users/%d/emails", uid) - req, err := s.client.NewRequest("POST", u, opt) + req, err := s.client.NewRequest("POST", u, opt, options) if err != nil { return nil, nil, err } @@ -560,10 +556,10 @@ func (s *UsersService) AddEmailForUser( // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#delete-email-for-current-owner -func (s *UsersService) DeleteEmail(eid int) (*Response, error) { +func (s *UsersService) DeleteEmail(eid int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("user/emails/%d", eid) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } @@ -576,10 +572,10 @@ func (s *UsersService) DeleteEmail(eid int) (*Response, error) { // // GitLab API docs: // https://docs.gitlab.com/ce/api/users.html#delete-email-for-given-user -func (s *UsersService) DeleteEmailForUser(uid int, eid int) (*Response, error) { +func (s *UsersService) DeleteEmailForUser(uid int, eid int, options ...OptionFunc) (*Response, error) { u := fmt.Sprintf("users/%d/emails/%d", uid, eid) - req, err := s.client.NewRequest("DELETE", u, nil) + req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { return nil, err } -- cgit v1.2.3