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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
11a9fbe6
Commit
11a9fbe6
authored
Mar 28, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the API project params reusable
parent
d5d7bcf8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
30 deletions
+42
-30
lib/api/helpers/projects_helpers.rb
lib/api/helpers/projects_helpers.rb
+38
-0
lib/api/projects.rb
lib/api/projects.rb
+4
-30
No files found.
lib/api/helpers/projects_helpers.rb
0 → 100644
View file @
11a9fbe6
module
API
module
Helpers
module
ProjectsHelpers
extend
ActiveSupport
::
Concern
included
do
helpers
do
params
:optional_project_params_ce
do
optional
:description
,
type:
String
,
desc:
'The description of the project'
optional
:ci_config_path
,
type:
String
,
desc:
'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional
:issues_enabled
,
type:
Boolean
,
desc:
'Flag indication if the issue tracker is enabled'
optional
:merge_requests_enabled
,
type:
Boolean
,
desc:
'Flag indication if merge requests are enabled'
optional
:wiki_enabled
,
type:
Boolean
,
desc:
'Flag indication if the wiki is enabled'
optional
:jobs_enabled
,
type:
Boolean
,
desc:
'Flag indication if jobs are enabled'
optional
:snippets_enabled
,
type:
Boolean
,
desc:
'Flag indication if snippets are enabled'
optional
:shared_runners_enabled
,
type:
Boolean
,
desc:
'Flag indication if shared runners are enabled for that project'
optional
:resolve_outdated_diff_discussions
,
type:
Boolean
,
desc:
'Automatically resolve merge request diffs discussions on lines changed with a push'
optional
:container_registry_enabled
,
type:
Boolean
,
desc:
'Flag indication if the container registry is enabled for that project'
optional
:lfs_enabled
,
type:
Boolean
,
desc:
'Flag indication if Git LFS is enabled for that project'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'The visibility of the project.'
optional
:public_builds
,
type:
Boolean
,
desc:
'Perform public builds'
optional
:request_access_enabled
,
type:
Boolean
,
desc:
'Allow users to request member access'
optional
:only_allow_merge_if_pipeline_succeeds
,
type:
Boolean
,
desc:
'Only allow to merge if builds succeed'
optional
:only_allow_merge_if_all_discussions_are_resolved
,
type:
Boolean
,
desc:
'Only allow to merge if all discussions are resolved'
optional
:tag_list
,
type:
Array
[
String
],
desc:
'The list of tags for a project'
optional
:avatar
,
type:
File
,
desc:
'Avatar image for project'
optional
:printing_merge_request_link_enabled
,
type:
Boolean
,
desc:
'Show link to create/view merge request when pushing from the command line'
optional
:merge_method
,
type:
String
,
values:
%w(ff rebase_merge merge)
,
desc:
'The merge method used when merging merge requests'
end
params
:optional_project_params
do
use
:optional_project_params_ce
end
end
end
end
end
end
lib/api/projects.rb
View file @
11a9fbe6
...
...
@@ -4,37 +4,11 @@ module API
class
Projects
<
Grape
::
API
include
PaginationParams
include
Helpers
::
CustomAttributes
include
Helpers
::
ProjectsHelpers
before
{
authenticate_non_get!
}
helpers
do
params
:optional_params_ce
do
optional
:description
,
type:
String
,
desc:
'The description of the project'
optional
:ci_config_path
,
type:
String
,
desc:
'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional
:issues_enabled
,
type:
Boolean
,
desc:
'Flag indication if the issue tracker is enabled'
optional
:merge_requests_enabled
,
type:
Boolean
,
desc:
'Flag indication if merge requests are enabled'
optional
:wiki_enabled
,
type:
Boolean
,
desc:
'Flag indication if the wiki is enabled'
optional
:jobs_enabled
,
type:
Boolean
,
desc:
'Flag indication if jobs are enabled'
optional
:snippets_enabled
,
type:
Boolean
,
desc:
'Flag indication if snippets are enabled'
optional
:shared_runners_enabled
,
type:
Boolean
,
desc:
'Flag indication if shared runners are enabled for that project'
optional
:resolve_outdated_diff_discussions
,
type:
Boolean
,
desc:
'Automatically resolve merge request diffs discussions on lines changed with a push'
optional
:container_registry_enabled
,
type:
Boolean
,
desc:
'Flag indication if the container registry is enabled for that project'
optional
:lfs_enabled
,
type:
Boolean
,
desc:
'Flag indication if Git LFS is enabled for that project'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'The visibility of the project.'
optional
:public_builds
,
type:
Boolean
,
desc:
'Perform public builds'
optional
:request_access_enabled
,
type:
Boolean
,
desc:
'Allow users to request member access'
optional
:only_allow_merge_if_pipeline_succeeds
,
type:
Boolean
,
desc:
'Only allow to merge if builds succeed'
optional
:only_allow_merge_if_all_discussions_are_resolved
,
type:
Boolean
,
desc:
'Only allow to merge if all discussions are resolved'
optional
:tag_list
,
type:
Array
[
String
],
desc:
'The list of tags for a project'
optional
:avatar
,
type:
File
,
desc:
'Avatar image for project'
optional
:printing_merge_request_link_enabled
,
type:
Boolean
,
desc:
'Show link to create/view merge request when pushing from the command line'
optional
:merge_method
,
type:
String
,
values:
%w(ff rebase_merge merge)
,
desc:
'The merge method used when merging merge requests'
end
params
:optional_params
do
use
:optional_params_ce
end
params
:statistics_params
do
optional
:statistics
,
type:
Boolean
,
default:
false
,
desc:
'Include project statistics'
end
...
...
@@ -144,7 +118,7 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the project'
optional
:path
,
type:
String
,
desc:
'The path of the repository'
at_least_one_of
:name
,
:path
use
:optional_params
use
:optional_p
roject_p
arams
use
:create_params
end
post
do
...
...
@@ -172,7 +146,7 @@ module API
requires
:user_id
,
type:
Integer
,
desc:
'The ID of a user'
optional
:path
,
type:
String
,
desc:
'The path of the repository'
optional
:default_branch
,
type:
String
,
desc:
'The default branch of the project'
use
:optional_params
use
:optional_p
roject_p
arams
use
:create_params
end
post
"user/:user_id"
do
...
...
@@ -293,7 +267,7 @@ module API
optional
:default_branch
,
type:
String
,
desc:
'The default branch of the project'
optional
:path
,
type:
String
,
desc:
'The path of the repository'
use
:optional_params
use
:optional_p
roject_p
arams
at_least_one_of
(
*
at_least_one_of_ce
)
end
put
':id'
do
...
...
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