Commit a3507a0c authored by Martin Sefcik's avatar Martin Sefcik

Added pagination parameters for all API calls where it is supported

parent 4b8992ab
......@@ -54,6 +54,7 @@ func (c Commit) String() string {
//
// GitLab API docs: http://doc.gitlab.com/ce/api/commits.html#list-commits
type ListCommitsOptions struct {
ListOptions
RefName string `url:"ref_name,omitempty"`
}
......
......@@ -35,7 +35,7 @@ func projectExample() {
}
// List all project snippets
snippets, _, err := git.ProjectSnippets.ListSnippits(project.PathWithNamespace)
snippets, _, err := git.ProjectSnippets.ListSnippets(project.PathWithNamespace)
if err != nil {
log.Fatal(err)
}
......
......@@ -40,12 +40,20 @@ type Group struct {
Projects *[]Project `json:"projects,omitempty"`
}
// ListGroupsOptions represents the available ListGroups() options.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#list-project-groups
type ListGroupsOptions struct {
ListOptions
Search string `url:"search,omitempty"`
}
// ListGroups gets a list of groups. (As user: my groups, as admin: all groups)
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/groups.html#list-project-groups
func (s *GroupsService) ListGroups() ([]*Group, *Response, error) {
req, err := s.client.NewRequest("GET", "groups", nil)
func (s *GroupsService) ListGroups(opt *ListGroupsOptions) ([]*Group, *Response, error) {
req, err := s.client.NewRequest("GET", "groups", opt)
if err != nil {
return nil, nil, err
}
......
......@@ -320,6 +320,15 @@ func (m MergeRequestComment) String() string {
return Stringify(m)
}
// GetMergeRequestCommentsOptions represents the available GetMergeRequestComments()
// options.
//
// GitLab API docs:
// http://doc.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.
//
......@@ -327,14 +336,15 @@ func (m MergeRequestComment) String() string {
// http://doc.gitlab.com/ce/api/merge_requests.html#get-the-comments-on-a-mr
func (s *MergeRequestsService) GetMergeRequestComments(
pid interface{},
mergeRequest int) ([]*MergeRequestComment, *Response, error) {
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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......
......@@ -54,6 +54,7 @@ func (m Milestone) String() string {
// GitLab API docs:
// http://doc.gitlab.com/ce/api/milestones.html#list-project-milestones
type ListMilestonesOptions struct {
ListOptions
IID int `url:"iid,omitempty"`
}
......@@ -187,20 +188,29 @@ func (s *MilestonesService) UpdateMilestone(
return m, resp, err
}
// GetMilestoneIssuesOptions represents the available GetMilestoneIssues() options.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/milestones.html#get-all-issues-assigned-to-a-single-milestone
type GetMilestoneIssuesOptions struct {
ListOptions
}
// GetMilestoneIssues gets all issues assigned to a single project milestone.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/milestones.html#get-all-issues-assigned-to-a-single-milestone
func (s *MilestonesService) GetMilestoneIssues(
pid interface{},
milestone int) ([]*Issue, *Response, error) {
milestone int,
opt *GetMilestoneIssuesOptions) ([]*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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......
......@@ -37,11 +37,19 @@ func (n Namespace) String() string {
return Stringify(n)
}
// ListNamespacesOptions represents the available ListNamespaces() options.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/namespaces.html#list-namespaces
type ListNamespacesOptions struct {
ListOptions
Search string `url:"search,omitempty"`
}
// ListNamespaces gets a list of projects accessible by the authenticated user.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/namespaces.html#list-namespaces
func (s *NamespacesService) ListNamespaces() ([]*Namespace, *Response, error) {
req, err := s.client.NewRequest("GET", "namespaces", nil)
func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions) ([]*Namespace, *Response, error) {
req, err := s.client.NewRequest("GET", "namespaces", opt)
if err != nil {
return nil, nil, err
}
......
......@@ -56,18 +56,29 @@ func (n Note) String() string {
return Stringify(n)
}
// ListIssueNotesOptions represents the available ListIssueNotes() options.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/notes.html#list-project-issue-notes
type ListIssueNotesOptions struct {
ListOptions
}
// ListIssueNotes gets a list of all notes for a single issue.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/notes.html#list-project-issue-notes
func (s *NotesService) ListIssueNotes(pid interface{}, issue int) ([]*Note, *Response, error) {
func (s *NotesService) ListIssueNotes(
pid interface{},
issue int,
opt *ListIssueNotesOptions) ([]*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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......
......@@ -55,17 +55,26 @@ func (s Snippet) String() string {
return Stringify(s)
}
// ListSnippits gets a list of project snippets.
// ListSnippetsOptions represents the available ListSnippets() options.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/project_snippets.html#list-snippets
func (s *ProjectSnippetsService) ListSnippits(pid interface{}) ([]*Snippet, *Response, error) {
type ListSnippetsOptions struct {
ListOptions
}
// ListSnippets gets a list of project snippets.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/project_snippets.html#list-snippets
func (s *ProjectSnippetsService) ListSnippets(
pid interface{},
opt *ListSnippetsOptions) ([]*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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......@@ -79,11 +88,11 @@ func (s *ProjectSnippetsService) ListSnippits(pid interface{}) ([]*Snippet, *Res
return ps, resp, err
}
// GetSnippit gets a single project snippet
// GetSnippet gets a single project snippet
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/project_snippets.html#single-snippet
func (s *ProjectSnippetsService) GetSnippit(
func (s *ProjectSnippetsService) GetSnippet(
pid interface{},
snippet int) (*Snippet, *Response, error) {
project, err := parseID(pid)
......@@ -211,11 +220,11 @@ func (s *ProjectSnippetsService) DeleteSnippet(pid interface{}, snippet int) (*R
return resp, err
}
// SnippitContent returns the raw project snippet as plain text.
// SnippetContent returns the raw project snippet as plain text.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/project_snippets.html#snippet-content
func (s *ProjectSnippetsService) SnippitContent(
func (s *ProjectSnippetsService) SnippetContent(
pid interface{},
snippet int) ([]byte, *Response, error) {
project, err := parseID(pid)
......
......@@ -76,6 +76,7 @@ func (s Project) String() string {
//
// GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-projects
type ListProjectsOptions struct {
ListOptions
Archived bool `url:"archived,omitempty"`
OrderBy string `url:"order_by,omitempty"`
Sort string `url:"sort,omitempty"`
......@@ -172,8 +173,7 @@ func (s *ProjectsService) GetProject(pid interface{}) (*Project, *Response, erro
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#search-for-projects-by-name
type SearchProjectsOptions struct {
PerPage int `url:"per_page,omitempty"`
Page int `url:"page,omitempty"`
ListOptions
OrderBy string `url:"order_by,omitempty"`
Sort string `url:"sort,omitempty"`
}
......@@ -245,19 +245,29 @@ func (s ProjectEvent) String() string {
return Stringify(s)
}
// GetProjectEventsOptions represents the available GetProjectEvents() options.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#get-project-events
type GetProjectEventsOptions struct {
ListOptions
}
// GetProjectEvents gets the events for the specified project. Sorted from
// newest to latest.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#get-project-events
func (s *ProjectsService) GetProjectEvents(pid interface{}) ([]*ProjectEvent, *Response, error) {
func (s *ProjectsService) GetProjectEvents(
pid interface{},
opt *GetProjectEventsOptions) ([]*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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......@@ -460,6 +470,7 @@ type ProjectMember struct {
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#list-project-team-members
type ListProjectMembersOptions struct {
ListOptions
Query string `url:"query,omitempty"`
}
......@@ -630,18 +641,27 @@ type ProjectHook struct {
CreatedAt time.Time `json:"created_at"`
}
// ListProjectHooksOptions represents the available ListProjectHooks() options.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-project-hooks
type ListProjectHooksOptions struct {
ListOptions
}
// ListProjectHooks gets a list of project hooks.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#list-project-hooks
func (s *ProjectsService) ListProjectHooks(pid interface{}) ([]*ProjectHook, *Response, error) {
func (s *ProjectsService) ListProjectHooks(
pid interface{},
opt *ListProjectHooksOptions) ([]*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, nil)
req, err := s.client.NewRequest("GET", u, opt)
if err != nil {
return nil, nil, err
}
......
......@@ -57,11 +57,20 @@ type User struct {
TwoFactorEnabled bool `json:"two_factor_enabled"`
}
// ListUsersOptions represents the available ListUsers() options.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/users.html#list-users
type ListUsersOptions struct {
ListOptions
Active bool `url:"active,omitempty"`
Search string `url:"search,omitempty"`
}
// ListUsers gets a list of users.
//
// GitLab API docs: http://doc.gitlab.com/ce/api/users.html#list-users
func (s *UsersService) ListUsers() ([]*User, *Response, error) {
req, err := s.client.NewRequest("GET", "users", nil)
func (s *UsersService) ListUsers(opt *ListUsersOptions) ([]*User, *Response, error) {
req, err := s.client.NewRequest("GET", "users", opt)
if err != nil {
return nil, nil, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment