Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
21e78957
Commit
21e78957
authored
May 15, 2018
by
Francisco Javier López
Committed by
Dennis Tang
May 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed API endpoint and specs
parent
92b4317d
Changes
97
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
97 changed files
with
356 additions
and
16029 deletions
+356
-16029
.codeclimate.yml
.codeclimate.yml
+0
-2
.rubocop_todo.yml
.rubocop_todo.yml
+0
-5
app/models/application_setting.rb
app/models/application_setting.rb
+0
-11
app/models/concerns/project_features_compatibility.rb
app/models/concerns/project_features_compatibility.rb
+1
-1
changelogs/unreleased/fj-36819-remove-v3-api.yml
changelogs/unreleased/fj-36819-remove-v3-api.yml
+5
-0
doc/api/README.md
doc/api/README.md
+7
-8
doc/api/applications.md
doc/api/applications.md
+1
-1
doc/api/environments.md
doc/api/environments.md
+1
-1
doc/api/projects.md
doc/api/projects.md
+1
-1
doc/api/v3_to_v4.md
doc/api/v3_to_v4.md
+3
-4
doc/integration/shibboleth.md
doc/integration/shibboleth.md
+1
-1
lib/api/api.rb
lib/api/api.rb
+5
-39
lib/api/v3/award_emoji.rb
lib/api/v3/award_emoji.rb
+0
-130
lib/api/v3/boards.rb
lib/api/v3/boards.rb
+0
-72
lib/api/v3/branches.rb
lib/api/v3/branches.rb
+0
-76
lib/api/v3/broadcast_messages.rb
lib/api/v3/broadcast_messages.rb
+0
-31
lib/api/v3/builds.rb
lib/api/v3/builds.rb
+0
-250
lib/api/v3/commits.rb
lib/api/v3/commits.rb
+0
-199
lib/api/v3/deploy_keys.rb
lib/api/v3/deploy_keys.rb
+0
-143
lib/api/v3/deployments.rb
lib/api/v3/deployments.rb
+0
-43
lib/api/v3/entities.rb
lib/api/v3/entities.rb
+0
-311
lib/api/v3/environments.rb
lib/api/v3/environments.rb
+0
-87
lib/api/v3/files.rb
lib/api/v3/files.rb
+0
-138
lib/api/v3/groups.rb
lib/api/v3/groups.rb
+0
-187
lib/api/v3/helpers.rb
lib/api/v3/helpers.rb
+0
-49
lib/api/v3/issues.rb
lib/api/v3/issues.rb
+0
-240
lib/api/v3/labels.rb
lib/api/v3/labels.rb
+0
-34
lib/api/v3/members.rb
lib/api/v3/members.rb
+0
-136
lib/api/v3/merge_request_diffs.rb
lib/api/v3/merge_request_diffs.rb
+0
-44
lib/api/v3/merge_requests.rb
lib/api/v3/merge_requests.rb
+0
-301
lib/api/v3/milestones.rb
lib/api/v3/milestones.rb
+0
-65
lib/api/v3/notes.rb
lib/api/v3/notes.rb
+0
-148
lib/api/v3/pipelines.rb
lib/api/v3/pipelines.rb
+0
-38
lib/api/v3/project_hooks.rb
lib/api/v3/project_hooks.rb
+0
-111
lib/api/v3/project_snippets.rb
lib/api/v3/project_snippets.rb
+0
-143
lib/api/v3/projects.rb
lib/api/v3/projects.rb
+0
-475
lib/api/v3/repositories.rb
lib/api/v3/repositories.rb
+0
-110
lib/api/v3/runners.rb
lib/api/v3/runners.rb
+0
-66
lib/api/v3/services.rb
lib/api/v3/services.rb
+0
-670
lib/api/v3/settings.rb
lib/api/v3/settings.rb
+0
-147
lib/api/v3/snippets.rb
lib/api/v3/snippets.rb
+0
-141
lib/api/v3/subscriptions.rb
lib/api/v3/subscriptions.rb
+0
-53
lib/api/v3/system_hooks.rb
lib/api/v3/system_hooks.rb
+0
-32
lib/api/v3/tags.rb
lib/api/v3/tags.rb
+0
-40
lib/api/v3/templates.rb
lib/api/v3/templates.rb
+0
-122
lib/api/v3/time_tracking_endpoints.rb
lib/api/v3/time_tracking_endpoints.rb
+0
-116
lib/api/v3/todos.rb
lib/api/v3/todos.rb
+0
-30
lib/api/v3/triggers.rb
lib/api/v3/triggers.rb
+0
-112
lib/api/v3/users.rb
lib/api/v3/users.rb
+0
-204
lib/api/v3/variables.rb
lib/api/v3/variables.rb
+0
-29
lib/gitlab/gitlab_import/client.rb
lib/gitlab/gitlab_import/client.rb
+5
-5
lib/gitlab/gitlab_import/importer.rb
lib/gitlab/gitlab_import/importer.rb
+1
-1
lib/gitlab/gitlab_import/project_creator.rb
lib/gitlab/gitlab_import/project_creator.rb
+1
-1
qa/spec/runtime/api_request_spec.rb
qa/spec/runtime/api_request_spec.rb
+1
-1
spec/fixtures/api/schemas/public_api/v3/issues.json
spec/fixtures/api/schemas/public_api/v3/issues.json
+0
-78
spec/fixtures/api/schemas/public_api/v3/merge_requests.json
spec/fixtures/api/schemas/public_api/v3/merge_requests.json
+0
-91
spec/lib/gitlab/gitlab_import/importer_spec.rb
spec/lib/gitlab/gitlab_import/importer_spec.rb
+2
-2
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+0
-16
spec/requests/api/v3/award_emoji_spec.rb
spec/requests/api/v3/award_emoji_spec.rb
+0
-297
spec/requests/api/v3/boards_spec.rb
spec/requests/api/v3/boards_spec.rb
+0
-114
spec/requests/api/v3/branches_spec.rb
spec/requests/api/v3/branches_spec.rb
+0
-120
spec/requests/api/v3/broadcast_messages_spec.rb
spec/requests/api/v3/broadcast_messages_spec.rb
+0
-32
spec/requests/api/v3/builds_spec.rb
spec/requests/api/v3/builds_spec.rb
+0
-550
spec/requests/api/v3/commits_spec.rb
spec/requests/api/v3/commits_spec.rb
+0
-603
spec/requests/api/v3/deploy_keys_spec.rb
spec/requests/api/v3/deploy_keys_spec.rb
+0
-179
spec/requests/api/v3/deployments_spec.rb
spec/requests/api/v3/deployments_spec.rb
+0
-69
spec/requests/api/v3/environments_spec.rb
spec/requests/api/v3/environments_spec.rb
+0
-163
spec/requests/api/v3/files_spec.rb
spec/requests/api/v3/files_spec.rb
+0
-283
spec/requests/api/v3/groups_spec.rb
spec/requests/api/v3/groups_spec.rb
+0
-566
spec/requests/api/v3/issues_spec.rb
spec/requests/api/v3/issues_spec.rb
+0
-1298
spec/requests/api/v3/labels_spec.rb
spec/requests/api/v3/labels_spec.rb
+0
-169
spec/requests/api/v3/members_spec.rb
spec/requests/api/v3/members_spec.rb
+0
-350
spec/requests/api/v3/merge_request_diffs_spec.rb
spec/requests/api/v3/merge_request_diffs_spec.rb
+0
-48
spec/requests/api/v3/merge_requests_spec.rb
spec/requests/api/v3/merge_requests_spec.rb
+0
-767
spec/requests/api/v3/milestones_spec.rb
spec/requests/api/v3/milestones_spec.rb
+0
-238
spec/requests/api/v3/notes_spec.rb
spec/requests/api/v3/notes_spec.rb
+0
-431
spec/requests/api/v3/pipelines_spec.rb
spec/requests/api/v3/pipelines_spec.rb
+0
-201
spec/requests/api/v3/project_hooks_spec.rb
spec/requests/api/v3/project_hooks_spec.rb
+0
-219
spec/requests/api/v3/project_snippets_spec.rb
spec/requests/api/v3/project_snippets_spec.rb
+0
-226
spec/requests/api/v3/projects_spec.rb
spec/requests/api/v3/projects_spec.rb
+0
-1495
spec/requests/api/v3/repositories_spec.rb
spec/requests/api/v3/repositories_spec.rb
+0
-366
spec/requests/api/v3/runners_spec.rb
spec/requests/api/v3/runners_spec.rb
+0
-152
spec/requests/api/v3/services_spec.rb
spec/requests/api/v3/services_spec.rb
+0
-26
spec/requests/api/v3/settings_spec.rb
spec/requests/api/v3/settings_spec.rb
+0
-63
spec/requests/api/v3/snippets_spec.rb
spec/requests/api/v3/snippets_spec.rb
+0
-186
spec/requests/api/v3/system_hooks_spec.rb
spec/requests/api/v3/system_hooks_spec.rb
+0
-56
spec/requests/api/v3/tags_spec.rb
spec/requests/api/v3/tags_spec.rb
+0
-88
spec/requests/api/v3/templates_spec.rb
spec/requests/api/v3/templates_spec.rb
+0
-201
spec/requests/api/v3/todos_spec.rb
spec/requests/api/v3/todos_spec.rb
+0
-77
spec/requests/api/v3/triggers_spec.rb
spec/requests/api/v3/triggers_spec.rb
+0
-235
spec/requests/api/v3/users_spec.rb
spec/requests/api/v3/users_spec.rb
+0
-362
spec/support/api/v3/time_tracking_shared_examples.rb
spec/support/api/v3/time_tracking_shared_examples.rb
+0
-128
spec/support/gitlab_stubs/project_8.json
spec/support/gitlab_stubs/project_8.json
+34
-34
spec/support/gitlab_stubs/projects.json
spec/support/gitlab_stubs/projects.json
+282
-1
spec/support/gitlab_stubs/session.json
spec/support/gitlab_stubs/session.json
+0
-18
spec/support/helpers/api_helpers.rb
spec/support/helpers/api_helpers.rb
+0
-11
spec/support/helpers/stub_gitlab_calls.rb
spec/support/helpers/stub_gitlab_calls.rb
+5
-15
No files found.
.codeclimate.yml
View file @
21e78957
...
...
@@ -8,8 +8,6 @@ engines:
languages
:
-
ruby
-
javascript
exclude_paths
:
-
"
lib/api/v3/*"
ratings
:
paths
:
-
Gemfile.lock
...
...
.rubocop_todo.yml
View file @
21e78957
...
...
@@ -173,7 +173,6 @@ Lint/UriEscapeUnescape:
-
'
spec/requests/api/files_spec.rb'
-
'
spec/requests/api/internal_spec.rb'
-
'
spec/requests/api/issues_spec.rb'
-
'
spec/requests/api/v3/issues_spec.rb'
# Offense count: 1
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
...
...
@@ -333,8 +332,6 @@ RSpec/ScatteredSetup:
-
'
spec/lib/gitlab/bitbucket_import/importer_spec.rb'
-
'
spec/lib/gitlab/git/env_spec.rb'
-
'
spec/requests/api/jobs_spec.rb'
-
'
spec/requests/api/v3/builds_spec.rb'
-
'
spec/requests/api/v3/projects_spec.rb'
-
'
spec/services/projects/create_service_spec.rb'
# Offense count: 1
...
...
@@ -618,7 +615,6 @@ Style/OrAssignment:
Exclude
:
-
'
app/models/concerns/token_authenticatable.rb'
-
'
lib/api/commit_statuses.rb'
-
'
lib/api/v3/members.rb'
-
'
lib/gitlab/project_transfer.rb'
# Offense count: 50
...
...
@@ -781,7 +777,6 @@ Style/TernaryParentheses:
-
'
app/finders/projects_finder.rb'
-
'
app/helpers/namespaces_helper.rb'
-
'
features/support/capybara.rb'
-
'
lib/api/v3/projects.rb'
-
'
lib/gitlab/ci/build/artifacts/metadata/entry.rb'
-
'
spec/requests/api/pipeline_schedules_spec.rb'
-
'
spec/support/capybara.rb'
...
...
app/models/application_setting.rb
View file @
21e78957
...
...
@@ -360,17 +360,6 @@ class ApplicationSetting < ActiveRecord::Base
Array
(
read_attribute
(
:repository_storages
))
end
# DEPRECATED
# repository_storage is still required in the API. Remove in 9.0
# Still used in API v3
def
repository_storage
repository_storages
.
first
end
def
repository_storage
=
(
value
)
self
.
repository_storages
=
[
value
]
end
def
default_project_visibility
=
(
level
)
super
(
Gitlab
::
VisibilityLevel
.
level_value
(
level
))
end
...
...
app/models/concerns/project_features_compatibility.rb
View file @
21e78957
# Makes api V
3
compatible with old project features permissions methods
# Makes api V
4
compatible with old project features permissions methods
#
# After migrating issues_enabled merge_requests_enabled builds_enabled snippets_enabled and wiki_enabled
# fields to a new table "project_features", support for the old fields is still needed in the API.
...
...
changelogs/unreleased/fj-36819-remove-v3-api.yml
0 → 100644
View file @
21e78957
---
title
:
Removed API v3 from the codebase
merge_request
:
18970
author
:
type
:
removed
doc/api/README.md
View file @
21e78957
...
...
@@ -90,24 +90,23 @@ specification.
## Compatibility Guidelines
The HTTP API is versioned using a single number, the current one being 4. This
number symbolises the same as the major version number as described by
number symbolises the same as the major version number as described by
[
SemVer
](
https://semver.org/
)
. This mean that backward incompatible changes
will require this version number to change. However, the minor version is
not explicit. This allows for a stable API endpoint, but also means new
not explicit. This allows for a stable API endpoint, but also means new
features can be added to the API in the same version number.
New features and bug fixes are released in tandem with a new GitLab, and apart
from incidental patch and security releases, are released on the 22nd each
month. Backward incompatible changes (e.g. endpoints removal, parameters
removal etc.), as well as removal of entire API versions are done in tandem
with a major point release of GitLab itself. All deprecations and changes
between two versions should be listed in the documentation. For the changes
month. Backward incompatible changes (e.g. endpoints removal, parameters
removal etc.), as well as removal of entire API versions are done in tandem
with a major point release of GitLab itself. All deprecations and changes
between two versions should be listed in the documentation. For the changes
between v3 and v4; please read the
[
v3 to v4 documentation
](
v3_to_v4.md
)
#### Current status
Currently two API versions are available, v3 and v4. v3 is deprecated and
will soon be removed. Deletion is scheduled for
Currently only API version v4 is available. Version v3 was removed in
[
GitLab 11.0
](
https://gitlab.com/gitlab-org/gitlab-ce/issues/36819
)
.
## Basic usage
...
...
doc/api/applications.md
View file @
21e78957
...
...
@@ -23,7 +23,7 @@ POST /applications
|
`scopes`
| string | yes | The scopes of the application |
```
bash
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
--data
"name=MyApplication&redirect_uri=http://redirect.uri&scopes="
https://gitlab.example.com/api/v
3
/applications
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
--data
"name=MyApplication&redirect_uri=http://redirect.uri&scopes="
https://gitlab.example.com/api/v
4
/applications
```
Example response:
...
...
doc/api/environments.md
View file @
21e78957
...
...
@@ -123,7 +123,7 @@ POST /projects/:id/environments/:environment_id/stop
|
`environment_id`
| integer | yes | The ID of the environment |
```
bash
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v
3
/projects/1/environments/1/stop"
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v
4
/projects/1/environments/1/stop"
```
Example response:
...
...
doc/api/projects.md
View file @
21e78957
...
...
@@ -1169,7 +1169,7 @@ The `file=` parameter must point to a file on your filesystem and be preceded
by
`@`
. For example:
```
bash
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
--form
"file=@dk.png"
https://gitlab.example.com/api/v
3
/projects/5/uploads
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
--form
"file=@dk.png"
https://gitlab.example.com/api/v
4
/projects/5/uploads
```
Returned object:
...
...
doc/api/v3_to_v4.md
View file @
21e78957
...
...
@@ -2,10 +2,9 @@
Since GitLab 9.0, API V4 is the preferred version to be used.
API V3 will be unsupported from GitLab 9.5, to be released on August
22, 2017. It will be removed in GitLab 9.5 or later. In the meantime, we advise
you to make any necessary changes to applications that use V3. The V3 API
documentation is still
API V3 was unsupported from GitLab 9.5, released on August
22, 2017. API v3 was removed in
[
GitLab 11.0
](
https://gitlab.com/gitlab-org/gitlab-ce/issues/36819
)
.
The V3 API documentation is still
[
available
](
https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/README.md
)
.
Below are the changes made between V3 and V4.
...
...
doc/integration/shibboleth.md
View file @
21e78957
...
...
@@ -107,7 +107,7 @@ you will not get a shibboleth session!
RewriteEngine on
#Don't escape encoded characters in api requests
RewriteCond %{REQUEST_URI} ^/api/v
3
/.*
RewriteCond %{REQUEST_URI} ^/api/v
4
/.*
RewriteCond %{REQUEST_URI} !/Shibboleth.sso
RewriteCond %{REQUEST_URI} !/shibboleth-sp
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
...
...
lib/api/api.rb
View file @
21e78957
...
...
@@ -22,48 +22,14 @@ module API
allow_access_with_scope
:api
prefix
:api
version
%w(v3 v4)
,
using: :path
version
'v3'
,
using: :path
do
helpers
::
API
::
V3
::
Helpers
helpers
::
API
::
Helpers
::
CommonHelpers
mount
::
API
::
V3
::
AwardEmoji
mount
::
API
::
V3
::
Boards
mount
::
API
::
V3
::
Branches
mount
::
API
::
V3
::
BroadcastMessages
mount
::
API
::
V3
::
Builds
mount
::
API
::
V3
::
Commits
mount
::
API
::
V3
::
DeployKeys
mount
::
API
::
V3
::
Environments
mount
::
API
::
V3
::
Files
mount
::
API
::
V3
::
Groups
mount
::
API
::
V3
::
Issues
mount
::
API
::
V3
::
Labels
mount
::
API
::
V3
::
Members
mount
::
API
::
V3
::
MergeRequestDiffs
mount
::
API
::
V3
::
MergeRequests
mount
::
API
::
V3
::
Notes
mount
::
API
::
V3
::
Pipelines
mount
::
API
::
V3
::
ProjectHooks
mount
::
API
::
V3
::
Milestones
mount
::
API
::
V3
::
Projects
mount
::
API
::
V3
::
ProjectSnippets
mount
::
API
::
V3
::
Repositories
mount
::
API
::
V3
::
Runners
mount
::
API
::
V3
::
Services
mount
::
API
::
V3
::
Settings
mount
::
API
::
V3
::
Snippets
mount
::
API
::
V3
::
Subscriptions
mount
::
API
::
V3
::
SystemHooks
mount
::
API
::
V3
::
Tags
mount
::
API
::
V3
::
Templates
mount
::
API
::
V3
::
Todos
mount
::
API
::
V3
::
Triggers
mount
::
API
::
V3
::
Users
mount
::
API
::
V3
::
Variables
route
:any
,
'*path'
do
error!
(
'API V3 is no longer supported. Use API V4 instead.'
,
410
)
end
end
version
'v4'
,
using: :path
before
do
header
[
'X-Frame-Options'
]
=
'SAMEORIGIN'
header
[
'X-Content-Type-Options'
]
=
'nosniff'
...
...
lib/api/v3/award_emoji.rb
deleted
100644 → 0
View file @
92b4317d
module
API
module
V3
class
AwardEmoji
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
AWARDABLES
=
%w[issue merge_request snippet]
.
freeze
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
AWARDABLES
.
each
do
|
awardable_type
|
awardable_string
=
awardable_type
.
pluralize
awardable_id_string
=
"
#{
awardable_type
}
_id"
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:"
#{
awardable_id_string
}
"
,
type:
Integer
,
desc:
"The ID of an Issue, Merge Request or Snippet"
end
[
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
,
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/notes/:note_id/award_emoji"
].
each
do
|
endpoint
|
desc
'Get a list of project +awardable+ award emoji'
do
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
=
awardable
.
award_emoji
present
paginate
(
awards
),
with:
Entities
::
AwardEmoji
else
not_found!
(
"Award Emoji"
)
end
end
desc
'Get a specific award emoji'
do
detail
'This feature was introduced in 8.9'
success
Entities
::
AwardEmoji
end
params
do
requires
:award_id
,
type:
Integer
,
desc:
'The ID of the award'
end
get
"
#{
endpoint
}
/:award_id"
do
if
can_read_awardable?
present
awardable
.
award_emoji
.
find
(
params
[
:award_id
]),
with:
Entities
::
AwardEmoji
else
not_found!
(
"Award Emoji"
)
end
end
desc
'Award a new Emoji'
do
detail
'This feature was introduced in 8.9'
success
Entities
::
AwardEmoji
end
params
do
requires
:name
,
type:
String
,
desc:
'The name of a award_emoji (without colons)'
end
post
endpoint
do
not_found!
(
'Award Emoji'
)
unless
can_read_awardable?
&&
can_award_awardable?
award
=
awardable
.
create_award_emoji
(
params
[
:name
],
current_user
)
if
award
.
persisted?
present
award
,
with:
Entities
::
AwardEmoji
else
not_found!
(
"Award Emoji
#{
award
.
errors
.
messages
}
"
)
end
end
desc
'Delete a +awardables+ award emoji'
do
detail
'This feature was introduced in 8.9'
success
Entities
::
AwardEmoji
end
params
do
requires
:award_id
,
type:
Integer
,
desc:
'The ID of an award emoji'
end
delete
"
#{
endpoint
}
/:award_id"
do
award
=
awardable
.
award_emoji
.
find
(
params
[
:award_id
])
unauthorized!
unless
award
.
user
==
current_user
||
current_user
.
admin?
award
.
destroy
present
award
,
with:
Entities
::
AwardEmoji
end
end
end
end
helpers
do
def
can_read_awardable?
can?
(
current_user
,
read_ability
(
awardable
),
awardable
)
end
def
can_award_awardable?
awardable
.
user_can_award?
(
current_user
,
params
[
:name
])
end
def
awardable
@awardable
||=
begin
if
params
.
include?
(
:note_id
)
note_id
=
params
.
delete
(
:note_id
)
awardable
.
notes
.
find
(
note_id
)
elsif
params
.
include?
(
:issue_id
)
user_project
.
issues
.
find
(
params
[
:issue_id
])
elsif
params
.
include?
(
:merge_request_id
)
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
else
user_project
.
snippets
.
find
(
params
[
:snippet_id
])
end
end
end
def
read_ability
(
awardable
)
case
awardable
when
Note
read_ability
(
awardable
.
noteable
)
else
:"read_
#{
awardable
.
class
.
to_s
.
underscore
}
"
end
end
end
end
end
end
lib/api/v3/boards.rb
deleted
100644 → 0
View file @
92b4317d
module
API
module
V3
class
Boards
<
Grape
::
API
before
{
authenticate!
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get all project boards'
do
detail
'This feature was introduced in 8.13'
success
::
API
::
Entities
::
Board
end
get
':id/boards'
do
authorize!
(
:read_board
,
user_project
)
present
user_project
.
boards
,
with:
::
API
::
Entities
::
Board
end
params
do
requires
:board_id
,
type:
Integer
,
desc:
'The ID of a board'
end
segment
':id/boards/:board_id'
do
helpers
do
def
project_board
board
=
user_project
.
boards
.
first
if
params
[
:board_id
]
==
board
.
id
board
else
not_found!
(
'Board'
)
end
end
def
board_lists
project_board
.
lists
.
destroyable
end
end
desc
'Get the lists of a project board'
do
detail
'Does not include `done` list. This feature was introduced in 8.13'
success
::
API
::
Entities
::
List
end
get
'/lists'
do
authorize!
(
:read_board
,
user_project
)
present
board_lists
,
with:
::
API
::
Entities
::
List
end
desc
'Delete a board list'
do
detail
'This feature was introduced in 8.13'
success
::
API
::
Entities
::
List
end
params
do
requires
:list_id
,
type:
Integer
,
desc:
'The ID of a board list'
end
delete
"/lists/:list_id"
do
authorize!
(
:admin_list
,
user_project
)
list
=
board_lists
.
find
(
params
[
:list_id
])
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
user_project
,
current_user
)
if
service
.
execute
(
list
)
present
list
,
with:
::
API
::
Entities
::
List
else
render_api_error!
({
error:
'List could not be deleted!'
},
400
)
end
end
end
end
end
end
end
lib/api/v3/branches.rb
deleted
100644 → 0
View file @
92b4317d
require
'mime/types'
module
API
module
V3
class
Branches
<
Grape
::
API
before
{
authenticate!
}
before
{
authorize!
:download_code
,
user_project
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get a project repository branches'
do
success
::
API
::
Entities
::
Branch
end
get
":id/repository/branches"
do
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42276'
)
repository
=
user_project
.
repository
branches
=
repository
.
branches
.
sort_by
(
&
:name
)
merged_branch_names
=
repository
.
merged_branch_names
(
branches
.
map
(
&
:name
))
present
branches
,
with:
::
API
::
Entities
::
Branch
,
project:
user_project
,
merged_branch_names:
merged_branch_names
end
desc
'Delete a branch'
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
end
delete
":id/repository/branches/:branch"
,
requirements:
{
branch:
/.+/
}
do
authorize_push_project
result
=
DeleteBranchService
.
new
(
user_project
,
current_user
)
.
execute
(
params
[
:branch
])
if
result
[
:status
]
==
:success
status
(
200
)
{
branch_name:
params
[
:branch
]
}
else
render_api_error!
(
result
[
:message
],
result
[
:return_code
])
end
end
desc
'Delete all merged branches'
delete
":id/repository/merged_branches"
do
DeleteMergedBranchesService
.
new
(
user_project
,
current_user
).
async_execute
status
(
200
)
end
desc
'Create branch'
do
success
::
API
::
Entities
::
Branch
end
params
do
requires
:branch_name
,
type:
String
,
desc:
'The name of the branch'
requires
:ref
,
type:
String
,
desc:
'Create branch from commit sha or existing branch'
end
post
":id/repository/branches"
do
authorize_push_project
result
=
CreateBranchService
.
new
(
user_project
,
current_user
)
.
execute
(
params
[
:branch_name
],
params
[
:ref
])
if
result
[
:status
]
==
:success
present
result
[
:branch
],
with:
::
API
::
Entities
::
Branch
,
project:
user_project
else
render_api_error!
(
result
[
:message
],
400
)
end
end
end
end
end
end
lib/api/v3/broadcast_messages.rb
deleted
100644 → 0
View file @
92b4317d
module
API
module
V3
class
BroadcastMessages
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
before
{
authenticated_as_admin!
}
resource
:broadcast_messages
do
helpers
do
def
find_message
BroadcastMessage
.
find
(
params
[
:id
])
end
end
desc
'Delete a broadcast message'
do
detail
'This feature was introduced in GitLab 8.12.'
success
::
API
::
Entities
::
BroadcastMessage
end
params
do
requires
:id
,
type:
Integer
,
desc:
'Broadcast message ID'
end
delete
':id'
do
message
=
find_message
present
message
.
destroy
,
with:
::
API
::
Entities
::
BroadcastMessage
end
end
end
end
end
lib/api/v3/builds.rb
deleted
100644 → 0
View file @
92b4317d
module
API
module
V3
class
Builds
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
helpers
do
params
:optional_scope
do
optional
:scope
,
types:
[
String
,
Array
[
String
]],
desc:
'The scope of builds to show'
,
values:
%w(pending running failed success canceled skipped)
,
coerce_with:
->
(
scope
)
{
if
scope
.
is_a?
(
String
)
[
scope
]
elsif
scope
.
is_a?
(
::
Hash
)
scope
.
values
else
[
'unknown'
]
end
}
end
end
desc
'Get a project builds'
do
success
::
API
::
V3
::
Entities
::
Build
end
params
do
use
:optional_scope
use
:pagination
end
get
':id/builds'
do
builds
=
user_project
.
builds
.
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
builds
.
preload
(
:user
,
:job_artifacts_archive
,
:runner
,
pipeline: :project
)
present
paginate
(
builds
),
with:
::
API
::
V3
::
Entities
::
Build
end
desc
'Get builds for a specific commit of a project'
do
success
::
API
::
V3
::
Entities
::
Build
end
params
do
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!
break
not_found!
unless
user_project
.
commit
(
params
[
:sha
])
pipelines
=
user_project
.
pipelines
.
where
(
sha:
params
[
:sha
])
builds
=
user_project
.
builds
.
where
(
pipeline:
pipelines
).
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
present
paginate
(
builds
),
with:
::
API
::
V3
::
Entities
::
Build
end
desc
'Get a specific build of a project'
do
success
::
API
::
V3
::
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
get
':id/builds/:build_id'
do
authorize_read_builds!
build
=
get_build!
(
params
[
:build_id
])
present
build
,
with:
::
API
::
V3
::
Entities
::
Build
end
desc
'Download the artifacts file from build'
do
detail
'This feature was introduced in GitLab 8.5'
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end