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
77cf855b
Commit
77cf855b
authored
Nov 22, 2016
by
Semyon Pupkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define common helper for describe pagination params in api
parent
53714ddf
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
12 deletions
+46
-12
changelogs/unreleased/23532-define-common-helper-for-describe-pagination-params-in-api.yml
...e-common-helper-for-describe-pagination-params-in-api.yml
+4
-0
lib/api/broadcast_messages.rb
lib/api/broadcast_messages.rb
+3
-2
lib/api/commits.rb
lib/api/commits.rb
+3
-2
lib/api/deployments.rb
lib/api/deployments.rb
+3
-2
lib/api/environments.rb
lib/api/environments.rb
+3
-2
lib/api/pagination_params.rb
lib/api/pagination_params.rb
+24
-0
lib/api/pipelines.rb
lib/api/pipelines.rb
+3
-2
lib/api/variables.rb
lib/api/variables.rb
+3
-2
No files found.
changelogs/unreleased/23532-define-common-helper-for-describe-pagination-params-in-api.yml
0 → 100644
View file @
77cf855b
---
title
:
Define common helper for describe pagination params in api
merge_request
:
7646
author
:
Semyon Pupkov
lib/api/broadcast_messages.rb
View file @
77cf855b
module
API
module
API
class
BroadcastMessages
<
Grape
::
API
class
BroadcastMessages
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
before
{
authenticated_as_admin!
}
before
{
authenticated_as_admin!
}
...
@@ -15,8 +17,7 @@ module API
...
@@ -15,8 +17,7 @@ module API
success
Entities
::
BroadcastMessage
success
Entities
::
BroadcastMessage
end
end
params
do
params
do
optional
:page
,
type:
Integer
,
desc:
'Current page number'
use
:pagination
optional
:per_page
,
type:
Integer
,
desc:
'Number of messages per page'
end
end
get
do
get
do
messages
=
BroadcastMessage
.
all
messages
=
BroadcastMessage
.
all
...
...
lib/api/commits.rb
View file @
77cf855b
...
@@ -3,6 +3,8 @@ require 'mime/types'
...
@@ -3,6 +3,8 @@ require 'mime/types'
module
API
module
API
# Projects commits API
# Projects commits API
class
Commits
<
Grape
::
API
class
Commits
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
before
{
authorize!
:download_code
,
user_project
}
before
{
authorize!
:download_code
,
user_project
}
...
@@ -107,9 +109,8 @@ module API
...
@@ -107,9 +109,8 @@ module API
failure
[[
404
,
'Not Found'
]]
failure
[[
404
,
'Not Found'
]]
end
end
params
do
params
do
use
:pagination
requires
:sha
,
type:
String
,
desc:
'A commit sha, or the name of a branch or tag'
requires
:sha
,
type:
String
,
desc:
'A commit sha, or the name of a branch or tag'
optional
:per_page
,
type:
Integer
,
desc:
'The amount of items per page for paginaion'
optional
:page
,
type:
Integer
,
desc:
'The page number for pagination'
end
end
get
':id/repository/commits/:sha/comments'
do
get
':id/repository/commits/:sha/comments'
do
commit
=
user_project
.
commit
(
params
[
:sha
])
commit
=
user_project
.
commit
(
params
[
:sha
])
...
...
lib/api/deployments.rb
View file @
77cf855b
module
API
module
API
# Deployments RESTfull API endpoints
# Deployments RESTfull API endpoints
class
Deployments
<
Grape
::
API
class
Deployments
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
params
do
params
do
...
@@ -12,8 +14,7 @@ module API
...
@@ -12,8 +14,7 @@ module API
success
Entities
::
Deployment
success
Entities
::
Deployment
end
end
params
do
params
do
optional
:page
,
type:
Integer
,
desc:
'Page number of the current request'
use
:pagination
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
end
end
get
':id/deployments'
do
get
':id/deployments'
do
authorize!
:read_deployment
,
user_project
authorize!
:read_deployment
,
user_project
...
...
lib/api/environments.rb
View file @
77cf855b
module
API
module
API
# Environments RESTfull API endpoints
# Environments RESTfull API endpoints
class
Environments
<
Grape
::
API
class
Environments
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
params
do
params
do
...
@@ -12,8 +14,7 @@ module API
...
@@ -12,8 +14,7 @@ module API
success
Entities
::
Environment
success
Entities
::
Environment
end
end
params
do
params
do
optional
:page
,
type:
Integer
,
desc:
'Page number of the current request'
use
:pagination
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
end
end
get
':id/environments'
do
get
':id/environments'
do
authorize!
:read_environment
,
user_project
authorize!
:read_environment
,
user_project
...
...
lib/api/pagination_params.rb
0 → 100644
View file @
77cf855b
module
API
# Concern for declare pagination params.
#
# @example
# class CustomApiResource < Grape::API
# include PaginationParams
#
# params do
# use :pagination
# end
# end
module
PaginationParams
extend
ActiveSupport
::
Concern
included
do
helpers
do
params
:pagination
do
optional
:page
,
type:
Integer
,
desc:
'Current page number'
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
end
end
end
end
end
lib/api/pipelines.rb
View file @
77cf855b
module
API
module
API
class
Pipelines
<
Grape
::
API
class
Pipelines
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
params
do
params
do
...
@@ -11,8 +13,7 @@ module API
...
@@ -11,8 +13,7 @@ module API
success
Entities
::
Pipeline
success
Entities
::
Pipeline
end
end
params
do
params
do
optional
:page
,
type:
Integer
,
desc:
'Page number of the current request'
use
:pagination
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
optional
:scope
,
type:
String
,
values:
[
'running'
,
'branches'
,
'tags'
],
optional
:scope
,
type:
String
,
values:
[
'running'
,
'branches'
,
'tags'
],
desc:
'Either running, branches, or tags'
desc:
'Either running, branches, or tags'
end
end
...
...
lib/api/variables.rb
View file @
77cf855b
module
API
module
API
# Projects variables API
# Projects variables API
class
Variables
<
Grape
::
API
class
Variables
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
before
{
authorize!
:admin_build
,
user_project
}
before
{
authorize!
:admin_build
,
user_project
}
...
@@ -13,8 +15,7 @@ module API
...
@@ -13,8 +15,7 @@ module API
success
Entities
::
Variable
success
Entities
::
Variable
end
end
params
do
params
do
optional
:page
,
type:
Integer
,
desc:
'The page number for pagination'
use
:pagination
optional
:per_page
,
type:
Integer
,
desc:
'The value of items per page to show'
end
end
get
':id/variables'
do
get
':id/variables'
do
variables
=
user_project
.
variables
variables
=
user_project
.
variables
...
...
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