Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f3a46373
Commit
f3a46373
authored
Dec 04, 2016
by
Robert Schilling
Committed by
Rémy Coutable
Dec 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the pagination helper in the API
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ef59a367
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
84 additions
and
20 deletions
+84
-20
lib/api/access_requests.rb
lib/api/access_requests.rb
+5
-0
lib/api/award_emoji.rb
lib/api/award_emoji.rb
+5
-0
lib/api/builds.rb
lib/api/builds.rb
+5
-2
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+3
-1
lib/api/groups.rb
lib/api/groups.rb
+10
-2
lib/api/members.rb
lib/api/members.rb
+4
-2
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+9
-0
lib/api/milestones.rb
lib/api/milestones.rb
+4
-1
lib/api/namespaces.rb
lib/api/namespaces.rb
+3
-1
lib/api/notes.rb
lib/api/notes.rb
+3
-1
lib/api/project_hooks.rb
lib/api/project_hooks.rb
+8
-4
lib/api/project_snippets.rb
lib/api/project_snippets.rb
+5
-1
lib/api/runners.rb
lib/api/runners.rb
+5
-0
lib/api/todos.rb
lib/api/todos.rb
+6
-4
lib/api/triggers.rb
lib/api/triggers.rb
+5
-0
lib/api/users.rb
lib/api/users.rb
+4
-1
No files found.
lib/api/access_requests.rb
View file @
f3a46373
module
API
class
AccessRequests
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
helpers
::
API
::
Helpers
::
MembersHelpers
...
...
@@ -13,6 +15,9 @@ module API
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
AccessRequester
end
params
do
use
:pagination
end
get
":id/access_requests"
do
source
=
find_source
(
source_type
,
params
[
:id
])
...
...
lib/api/award_emoji.rb
View file @
f3a46373
module
API
class
AwardEmoji
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
AWARDABLES
=
%w[issue merge_request snippet]
...
...
@@ -21,6 +23,9 @@ module API
detail
'This feature was introduced in 8.9'
success
Entities
::
AwardEmoji
end
params
do
use
:pagination
end
get
endpoint
do
if
can_read_awardable?
awards
=
paginate
(
awardable
.
award_emoji
)
...
...
lib/api/builds.rb
View file @
f3a46373
module
API
# Projects builds API
class
Builds
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
params
do
...
...
@@ -28,6 +29,7 @@ module API
end
params
do
use
:optional_scope
use
:pagination
end
get
':id/builds'
do
builds
=
user_project
.
builds
.
order
(
'id DESC'
)
...
...
@@ -41,8 +43,9 @@ module API
success
Entities
::
Build
end
params
do
requires
:sha
,
type:
String
,
desc:
'The SHA id of a commit'
requires
:sha
,
type:
String
,
desc:
'The SHA id of a commit'
use
:optional_scope
use
:pagination
end
get
':id/repository/commits/:sha/builds'
do
authorize_read_builds!
...
...
lib/api/commit_statuses.rb
View file @
f3a46373
require
'mime/types'
module
API
# Project commit statuses API
class
CommitStatuses
<
Grape
::
API
resource
:projects
do
include
PaginationParams
before
{
authenticate!
}
desc
"Get a commit's statuses"
do
...
...
@@ -16,6 +17,7 @@ module API
optional
:stage
,
type:
String
,
desc:
'The stage'
optional
:name
,
type:
String
,
desc:
'The name'
optional
:all
,
type:
String
,
desc:
'Show all statuses, default: false'
use
:pagination
end
get
':id/repository/commits/:sha/statuses'
do
authorize!
(
:read_commit_status
,
user_project
)
...
...
lib/api/groups.rb
View file @
f3a46373
module
API
class
Groups
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
helpers
do
...
...
@@ -29,6 +31,7 @@ module API
optional
:search
,
type:
String
,
desc:
'Search for a specific group'
optional
:order_by
,
type:
String
,
values:
%w[name path]
,
default:
'name'
,
desc:
'Order by name or path'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'asc'
,
desc:
'Sort by asc (ascending) or desc (descending)'
use
:pagination
end
get
do
groups
=
if
current_user
.
admin
...
...
@@ -49,6 +52,9 @@ module API
desc
'Get list of owned groups for authenticated user'
do
success
Entities
::
Group
end
params
do
use
:pagination
end
get
'/owned'
do
groups
=
current_user
.
owned_groups
present
paginate
(
groups
),
with:
Entities
::
Group
,
user:
current_user
...
...
@@ -132,11 +138,13 @@ module API
desc
'Get a list of projects in this group.'
do
success
Entities
::
Project
end
params
do
use
:pagination
end
get
":id/projects"
do
group
=
find_group!
(
params
[
:id
])
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
paginate
projects
present
projects
,
with:
Entities
::
Project
,
user:
current_user
present
paginate
(
projects
),
with:
Entities
::
Project
,
user:
current_user
end
desc
'Transfer a project to the group namespace. Available only for admin.'
do
...
...
lib/api/members.rb
View file @
f3a46373
module
API
class
Members
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
helpers
::
API
::
Helpers
::
MembersHelpers
...
...
@@ -14,15 +16,15 @@ module API
end
params
do
optional
:query
,
type:
String
,
desc:
'A query string to search for members'
use
:pagination
end
get
":id/members"
do
source
=
find_source
(
source_type
,
params
[
:id
])
users
=
source
.
users
users
=
users
.
merge
(
User
.
search
(
params
[
:query
]))
if
params
[
:query
]
users
=
paginate
(
users
)
present
users
,
with:
Entities
::
Member
,
source:
source
present
paginate
(
users
)
,
with:
Entities
::
Member
,
source:
source
end
desc
'Gets a member of a group or project.'
do
...
...
lib/api/merge_requests.rb
View file @
f3a46373
module
API
class
MergeRequests
<
Grape
::
API
include
PaginationParams
DEPRECATION_MESSAGE
=
'This endpoint is deprecated and will be removed in GitLab 9.0.'
.
freeze
before
{
authenticate!
}
...
...
@@ -43,6 +45,7 @@ module API
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
desc:
'Return merge requests sorted in `asc` or `desc` order.'
optional
:iid
,
type:
Array
[
Integer
],
desc:
'The IID of the merge requests'
use
:pagination
end
get
":id/merge_requests"
do
authorize!
:read_merge_request
,
user_project
...
...
@@ -219,6 +222,9 @@ module API
detail
'Duplicate. DEPRECATED and WILL BE REMOVED in 9.0'
success
Entities
::
MRNote
end
params
do
use
:pagination
end
get
"
#{
path
}
/comments"
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
...
...
@@ -256,6 +262,9 @@ module API
desc
'List issues that will be closed on merge'
do
success
Entities
::
MRNote
end
params
do
use
:pagination
end
get
"
#{
path
}
/closes_issues"
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
issues
=
::
Kaminari
.
paginate_array
(
merge_request
.
closes_issues
(
current_user
))
...
...
lib/api/milestones.rb
View file @
f3a46373
module
API
# Milestones API
class
Milestones
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
helpers
do
...
...
@@ -30,6 +31,7 @@ module API
optional
:state
,
type:
String
,
values:
%w[active closed all]
,
default:
'all'
,
desc:
'Return "active", "closed", or "all" milestones'
optional
:iid
,
type:
Array
[
Integer
],
desc:
'The IID of the milestone'
use
:pagination
end
get
":id/milestones"
do
authorize!
:read_milestone
,
user_project
...
...
@@ -103,6 +105,7 @@ module API
end
params
do
requires
:milestone_id
,
type:
Integer
,
desc:
'The ID of a project milestone'
use
:pagination
end
get
":id/milestones/:milestone_id/issues"
do
authorize!
:read_milestone
,
user_project
...
...
lib/api/namespaces.rb
View file @
f3a46373
module
API
# namespaces API
class
Namespaces
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
resource
:namespaces
do
...
...
@@ -9,6 +10,7 @@ module API
end
params
do
optional
:search
,
type:
String
,
desc:
"Search query for namespaces"
use
:pagination
end
get
do
namespaces
=
current_user
.
admin
?
Namespace
.
all
:
current_user
.
namespaces
...
...
lib/api/notes.rb
View file @
f3a46373
module
API
# Notes API
class
Notes
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
NOTEABLE_TYPES
=
[
Issue
,
MergeRequest
,
Snippet
]
...
...
@@ -17,6 +18,7 @@ module API
end
params
do
requires
:noteable_id
,
type:
Integer
,
desc:
'The ID of the noteable'
use
:pagination
end
get
":id/
#{
noteables_str
}
/:noteable_id/notes"
do
noteable
=
user_project
.
send
(
noteables_str
.
to_sym
).
find
(
params
[
:noteable_id
])
...
...
lib/api/project_hooks.rb
View file @
f3a46373
module
API
# Projects API
class
ProjectHooks
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authorize_admin_project
}
helpers
do
params
:project_hook_properties
do
requires
:url
,
type:
String
,
desc:
"The URL to send the request to"
...
...
@@ -17,9 +21,6 @@ module API
end
end
before
{
authenticate!
}
before
{
authorize_admin_project
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
...
...
@@ -27,6 +28,9 @@ module API
desc
'Get project hooks'
do
success
Entities
::
ProjectHook
end
params
do
use
:pagination
end
get
":id/hooks"
do
hooks
=
paginate
user_project
.
hooks
...
...
lib/api/project_snippets.rb
View file @
f3a46373
module
API
# Projects API
class
ProjectSnippets
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
params
do
...
...
@@ -24,6 +25,9 @@ module API
desc
'Get all project snippets'
do
success
Entities
::
ProjectSnippet
end
params
do
use
:pagination
end
get
":id/snippets"
do
present
paginate
(
snippets_for_current_user
),
with:
Entities
::
ProjectSnippet
end
...
...
lib/api/runners.rb
View file @
f3a46373
module
API
class
Runners
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
resource
:runners
do
...
...
@@ -9,6 +11,7 @@ module API
params
do
optional
:scope
,
type:
String
,
values:
%w[active paused online]
,
desc:
'The scope of specific runners to show'
use
:pagination
end
get
do
runners
=
filter_runners
(
current_user
.
ci_authorized_runners
,
params
[
:scope
],
without:
[
'specific'
,
'shared'
])
...
...
@@ -21,6 +24,7 @@ module API
params
do
optional
:scope
,
type:
String
,
values:
%w[active paused online specific shared]
,
desc:
'The scope of specific runners to show'
use
:pagination
end
get
'all'
do
authenticated_as_admin!
...
...
@@ -91,6 +95,7 @@ module API
params
do
optional
:scope
,
type:
String
,
values:
%w[active paused online specific shared]
,
desc:
'The scope of specific runners to show'
use
:pagination
end
get
':id/runners'
do
runners
=
filter_runners
(
Ci
::
Runner
.
owned_or_shared
(
user_project
.
id
),
params
[
:scope
])
...
...
lib/api/todos.rb
View file @
f3a46373
module
API
# Todos API
class
Todos
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
ISSUABLE_TYPES
=
{
...
...
@@ -44,10 +45,11 @@ module API
desc
'Get a todo list'
do
success
Entities
::
Todo
end
params
do
use
:pagination
end
get
do
todos
=
find_todos
present
paginate
(
todos
),
with:
Entities
::
Todo
,
current_user:
current_user
present
paginate
(
find_todos
),
with:
Entities
::
Todo
,
current_user:
current_user
end
desc
'Mark a todo as done'
do
...
...
lib/api/triggers.rb
View file @
f3a46373
module
API
class
Triggers
<
Grape
::
API
include
PaginationParams
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
...
...
@@ -42,6 +44,9 @@ module API
desc
'Get triggers list'
do
success
Entities
::
Trigger
end
params
do
use
:pagination
end
get
':id/triggers'
do
authenticate!
authorize!
:admin_build
,
user_project
...
...
lib/api/users.rb
View file @
f3a46373
module
API
# Users API
class
Users
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
resource
:users
,
requirements:
{
uid:
/[0-9]*/
,
id:
/[0-9]*/
}
do
...
...
@@ -34,6 +35,7 @@ module API
optional
:external
,
type:
Boolean
,
default:
false
,
desc:
'Filters only external users'
optional
:blocked
,
type:
Boolean
,
default:
false
,
desc:
'Filters only blocked users'
optional
:skip_ldap
,
type:
Boolean
,
default:
false
,
desc:
'Skip LDAP users'
use
:pagination
end
get
do
unless
can?
(
current_user
,
:read_users_list
,
nil
)
...
...
@@ -332,6 +334,7 @@ module API
end
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the user'
use
:pagination
end
get
':id/events'
do
user
=
User
.
find_by
(
id:
params
[
:id
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment