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
Jérome Perrin
gitlab-ce
Commits
37c4ba6f
Commit
37c4ba6f
authored
Jul 28, 2014
by
Sasha Joseph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an option to GET /projects in the GitLab API to exclude archived projects
parent
00c67238
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
doc/api/projects.md
doc/api/projects.md
+6
-2
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
lib/api/projects.rb
lib/api/projects.rb
+10
-2
No files found.
doc/api/projects.md
View file @
37c4ba6f
...
...
@@ -8,6 +8,10 @@ Get a list of projects accessible by the authenticated user.
GET /projects
```
Parameters:
+
`archived`
(optional) - if passed, limit by archived status
```
json
[
{
...
...
@@ -250,7 +254,7 @@ Parameters:
+
`description`
(optional) - short project description
+
`issues_enabled`
(optional)
+
`merge_requests_enabled`
(optional)
+
`wiki_enabled`
(optional)
+
`wiki_enabled`
(optional)
+
`snippets_enabled`
(optional)
+
`public`
(optional) - if
`true`
same as setting visibility_level = 20
+
`visibility_level`
(optional)
...
...
@@ -273,7 +277,7 @@ Parameters:
+
`default_branch`
(optional) - 'master' by default
+
`issues_enabled`
(optional)
+
`merge_requests_enabled`
(optional)
+
`wiki_enabled`
(optional)
+
`wiki_enabled`
(optional)
+
`snippets_enabled`
(optional)
+
`public`
(optional) - if
`true`
same as setting visibility_level = 20
+
`visibility_level`
(optional)
...
...
lib/api/helpers.rb
View file @
37c4ba6f
...
...
@@ -5,6 +5,10 @@ module API
SUDO_HEADER
=
"HTTP_SUDO"
SUDO_PARAM
=
:sudo
def
parse_boolean
(
value
)
[
true
,
1
,
'1'
,
't'
,
'T'
,
'true'
,
'TRUE'
,
'on'
,
'ON'
].
include?
(
value
)
end
def
current_user
private_token
=
(
params
[
PRIVATE_TOKEN_PARAM
]
||
env
[
PRIVATE_TOKEN_HEADER
]).
to_s
@current_user
||=
User
.
find_by
(
authentication_token:
private_token
)
...
...
lib/api/projects.rb
View file @
37c4ba6f
...
...
@@ -7,7 +7,7 @@ module API
helpers
do
def
map_public_to_visibility_level
(
attrs
)
publik
=
attrs
.
delete
(
:public
)
publik
=
[
true
,
1
,
'1'
,
't'
,
'T'
,
'true'
,
'TRUE'
,
'on'
,
'ON'
].
include?
(
publik
)
publik
=
parse_boolean
(
publik
)
attrs
[
:visibility_level
]
=
Gitlab
::
VisibilityLevel
::
PUBLIC
if
!
attrs
[
:visibility_level
].
present?
&&
publik
==
true
attrs
end
...
...
@@ -15,10 +15,18 @@ module API
# Get a projects list for authenticated user
#
# Parameters:
# archived (optional) - if passed, limit by archived status
#
# Example Request:
# GET /projects
get
do
@projects
=
paginate
current_user
.
authorized_projects
@query
=
current_user
.
authorized_projects
# If the archived parameter is passed, limit results accordingly
if
params
[
:archived
].
present?
@query
=
@query
.
where
(
archived:
parse_boolean
(
params
[
:archived
]))
end
@projects
=
paginate
@query
present
@projects
,
with:
Entities
::
Project
end
...
...
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