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
ea178142
Commit
ea178142
authored
Jan 07, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
764c690d
052b5a88
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
551 additions
and
9 deletions
+551
-9
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/release/links.rb
lib/api/release/links.rb
+117
-0
spec/fixtures/api/schemas/release.json
spec/fixtures/api/schemas/release.json
+1
-9
spec/fixtures/api/schemas/release/link.json
spec/fixtures/api/schemas/release/link.json
+11
-0
spec/fixtures/api/schemas/release/links.json
spec/fixtures/api/schemas/release/links.json
+4
-0
spec/requests/api/release/links_spec.rb
spec/requests/api/release/links_spec.rb
+417
-0
No files found.
lib/api/api.rb
View file @
ea178142
...
...
@@ -151,6 +151,7 @@ module API
mount
::
API
::
ProtectedBranches
mount
::
API
::
ProtectedTags
mount
::
API
::
Releases
mount
::
API
::
Release
::
Links
mount
::
API
::
Repositories
mount
::
API
::
Runner
mount
::
API
::
Runners
...
...
lib/api/release/links.rb
0 → 100644
View file @
ea178142
# frozen_string_literal: true
module
API
module
Release
class
Links
<
Grape
::
API
include
PaginationParams
RELEASE_ENDPOINT_REQUIREMETS
=
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
.
merge
(
tag_name:
API
::
NO_SLASH_URL_PART_REGEX
)
before
{
error!
(
'404 Not Found'
,
404
)
unless
Feature
.
enabled?
(
:releases_page
,
user_project
)
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
'projects/:id'
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
params
do
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
,
as: :tag
end
resource
'releases/:tag_name'
,
requirements:
RELEASE_ENDPOINT_REQUIREMETS
do
resource
:assets
do
desc
'Get a list of links of a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Releases
::
Link
end
params
do
use
:pagination
end
get
'links'
do
authorize!
:read_release
,
release
present
paginate
(
release
.
links
.
sorted
),
with:
Entities
::
Releases
::
Link
end
desc
'Create a link of a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Releases
::
Link
end
params
do
requires
:name
,
type:
String
,
desc:
'The name of the link'
requires
:url
,
type:
String
,
desc:
'The URL of the link'
end
post
'links'
do
authorize!
:create_release
,
release
new_link
=
release
.
links
.
create
(
declared_params
(
include_missing:
false
))
if
new_link
.
persisted?
present
new_link
,
with:
Entities
::
Releases
::
Link
else
render_api_error!
(
new_link
.
errors
.
messages
,
400
)
end
end
params
do
requires
:link_id
,
type:
String
,
desc:
'The id of the link'
end
resource
'links/:link_id'
do
desc
'Get a link detail of a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Releases
::
Link
end
get
do
authorize!
:read_release
,
release
present
link
,
with:
Entities
::
Releases
::
Link
end
desc
'Update a link of a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Releases
::
Link
end
params
do
optional
:name
,
type:
String
,
desc:
'The name of the link'
optional
:url
,
type:
String
,
desc:
'The URL of the link'
at_least_one_of
:name
,
:url
end
put
do
authorize!
:update_release
,
release
if
link
.
update
(
declared_params
(
include_missing:
false
))
present
link
,
with:
Entities
::
Releases
::
Link
else
render_api_error!
(
link
.
errors
.
messages
,
400
)
end
end
desc
'Delete a link of a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Releases
::
Link
end
delete
do
authorize!
:destroy_release
,
release
if
link
.
destroy
present
link
,
with:
Entities
::
Releases
::
Link
else
render_api_error!
(
link
.
errors
.
messages
,
400
)
end
end
end
end
end
end
helpers
do
def
release
@release
||=
user_project
.
releases
.
find_by_tag!
(
params
[
:tag
])
end
def
link
@link
||=
release
.
links
.
find
(
params
[
:link_id
])
end
end
end
end
end
spec/fixtures/api/schemas/release.json
View file @
ea178142
...
...
@@ -15,15 +15,7 @@
},
"assets"
:
{
"count"
:
{
"type"
:
"integer"
},
"links"
:
{
"type"
:
"array"
,
"items"
:
{
"id"
:
"integer"
,
"name"
:
"string"
,
"url"
:
"string"
,
"external"
:
"boolean"
}
},
"links"
:
{
"$ref"
:
"release/links.json"
},
"sources"
:
{
"type"
:
"array"
,
"items"
:
{
...
...
spec/fixtures/api/schemas/release/link.json
0 → 100644
View file @
ea178142
{
"type"
:
"object"
,
"required"
:
[
"name"
,
"url"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"name"
:
{
"type"
:
"string"
},
"url"
:
{
"type"
:
"string"
},
"external"
:
{
"type"
:
"boolean"
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/release/links.json
0 → 100644
View file @
ea178142
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"link.json"
}
}
spec/requests/api/release/links_spec.rb
0 → 100644
View file @
ea178142
This diff is collapsed.
Click to expand it.
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