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
4c46c9a9
Commit
4c46c9a9
authored
Oct 14, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify boards API
parent
4b889dbb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
31 deletions
+45
-31
lib/api/boards.rb
lib/api/boards.rb
+45
-31
No files found.
lib/api/boards.rb
View file @
4c46c9a9
...
@@ -3,19 +3,28 @@ module API
...
@@ -3,19 +3,28 @@ module API
class
Boards
<
Grape
::
API
class
Boards
<
Grape
::
API
before
{
authenticate!
}
before
{
authenticate!
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
resource
:projects
do
# Get the project board
desc
'Get all project boards'
do
detail
'This feature was introduced in 8.13'
success
Entities
::
Board
end
get
':id/boards'
do
get
':id/boards'
do
authorize!
(
:read_board
,
user_project
)
authorize!
(
:read_board
,
user_project
)
present
user_project
.
boards
,
with:
Entities
::
Board
present
user_project
.
boards
,
with:
Entities
::
Board
end
end
params
do
requires
:board_id
,
type:
Integer
,
desc:
'The ID of a board'
end
segment
':id/boards/:board_id'
do
segment
':id/boards/:board_id'
do
helpers
do
helpers
do
def
project_board
def
project_board
board
=
user_project
.
boards
.
first
board
=
user_project
.
boards
.
first
if
params
[
:board_id
]
.
to_i
==
board
.
id
if
params
[
:board_id
]
==
board
.
id
board
board
else
else
not_found!
(
'Board'
)
not_found!
(
'Board'
)
...
@@ -27,29 +36,35 @@ module API
...
@@ -27,29 +36,35 @@ module API
end
end
end
end
# Get the lists of a project board
desc
'Get the lists of a project board'
do
# Does not include `backlog` and `done` lists
detail
'Does not include `backlog` and `done` lists. This feature was introduced in 8.13'
success
Entities
::
List
end
get
'/lists'
do
get
'/lists'
do
authorize!
(
:read_board
,
user_project
)
authorize!
(
:read_board
,
user_project
)
present
board_lists
,
with:
Entities
::
List
present
board_lists
,
with:
Entities
::
List
end
end
# Get a list of a project board
desc
'Get a list of a project board'
do
detail
'This feature was introduced in 8.13'
success
Entities
::
List
end
params
do
requires
:list_id
,
type:
Integer
,
desc:
'The ID of a list'
end
get
'/lists/:list_id'
do
get
'/lists/:list_id'
do
authorize!
(
:read_board
,
user_project
)
authorize!
(
:read_board
,
user_project
)
present
board_lists
.
find
(
params
[
:list_id
]),
with:
Entities
::
List
present
board_lists
.
find
(
params
[
:list_id
]),
with:
Entities
::
List
end
end
# Create a new board list
desc
'Create a new board list'
do
#
detail
'This feature was introduced in 8.13'
# Parameters:
success
Entities
::
List
# id (required) - The ID of a project
end
# label_id (required) - The ID of an existing label
params
do
# Example Request:
requires
:label_id
,
type:
Integer
,
desc:
'The ID of an existing label'
# POST /projects/:id/boards/:board_id/lists
end
post
'/lists'
do
post
'/lists'
do
required_attributes!
[
:label_id
]
unless
user_project
.
labels
.
exists?
(
params
[
:label_id
])
unless
user_project
.
labels
.
exists?
(
params
[
:label_id
])
render_api_error!
({
error:
"Label not found!"
},
400
)
render_api_error!
({
error:
"Label not found!"
},
400
)
end
end
...
@@ -68,21 +83,21 @@ module API
...
@@ -68,21 +83,21 @@ module API
end
end
end
end
# Moves a board list to a new position
desc
'Moves a board list to a new position'
do
#
detail
'This feature was introduced in 8.13'
# Parameters:
success
Entities
::
List
# id (required) - The ID of a project
end
# board_id (required) - The ID of a board
params
do
# position (required) - The position of the list
requires
:list_id
,
type:
Integer
,
desc:
'The ID of a list'
# Example Request:
requires
:position
,
type:
Integer
,
desc:
'The position of the list'
# PUT /projects/:id/boards/:board_id/lists/:list_i
d
en
d
put
'/lists/:list_id'
do
put
'/lists/:list_id'
do
list
=
project_board
.
lists
.
movable
.
find
(
params
[
:list_id
])
list
=
project_board
.
lists
.
movable
.
find
(
params
[
:list_id
])
authorize!
(
:admin_list
,
user_project
)
authorize!
(
:admin_list
,
user_project
)
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
{
position:
params
[
:position
]
.
to_i
})
{
position:
params
[
:position
]
})
if
service
.
execute
(
list
)
if
service
.
execute
(
list
)
present
list
,
with:
Entities
::
List
present
list
,
with:
Entities
::
List
...
@@ -91,14 +106,13 @@ module API
...
@@ -91,14 +106,13 @@ module API
end
end
end
end
# Delete a board list
desc
'Delete a board list'
do
#
detail
'This feature was introduced in 8.13'
# Parameters:
success
Entities
::
List
# id (required) - The ID of a project
end
# board_id (required) - The ID of a board
params
do
# list_id (required) - The ID of a board list
requires
:list_id
,
type:
Integer
,
desc:
'The ID of a board list'
# Example Request:
end
# DELETE /projects/:id/boards/:board_id/lists/:list_id
delete
"/lists/:list_id"
do
delete
"/lists/:list_id"
do
authorize!
(
:admin_list
,
user_project
)
authorize!
(
:admin_list
,
user_project
)
...
...
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