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
e956a24d
Commit
e956a24d
authored
Aug 23, 2016
by
Ben Boeckel
Committed by
Sean McGivern
Oct 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api: add /projects/visible API endpoint
FIxes #19361, #3119.
parent
b6b50335
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
0 deletions
+156
-0
CHANGELOG
CHANGELOG
+1
-0
doc/api/projects.md
doc/api/projects.md
+129
-0
lib/api/projects.rb
lib/api/projects.rb
+15
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+11
-0
No files found.
CHANGELOG
View file @
e956a24d
...
...
@@ -155,6 +155,7 @@ v 8.12.0
- Test migration paths from 8.5 until current release !4874
- Replace animateEmoji timeout with eventListener (ClemMakesApps)
- Show badges in Milestone tabs. !5946 (Dan Rowden)
- Add `/projects/visible` API endpoint (Ben Boeckel)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Require confirmation when not logged in for unsubscribe links !6223 (Maximiliano Perez Coto)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel)
...
...
doc/api/projects.md
View file @
e956a24d
...
...
@@ -153,6 +153,135 @@ Parameters:
]
```
Get a list of projects for which the authenticated user can see.
```
GET /projects/visible
```
Parameters:
-
`archived`
(optional) - if passed, limit by archived status
-
`visibility`
(optional) - if passed, limit by visibility
`public`
,
`internal`
,
`private`
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`search`
(optional) - Return list of authorized projects according to a search criteria
```
json
[
{
"id"
:
4
,
"description"
:
null
,
"default_branch"
:
"master"
,
"public"
:
false
,
"visibility_level"
:
0
,
"ssh_url_to_repo"
:
"git@example.com:diaspora/diaspora-client.git"
,
"http_url_to_repo"
:
"http://example.com/diaspora/diaspora-client.git"
,
"web_url"
:
"http://example.com/diaspora/diaspora-client"
,
"tag_list"
:
[
"example"
,
"disapora client"
],
"owner"
:
{
"id"
:
3
,
"name"
:
"Diaspora"
,
"created_at"
:
"2013-09-30T13:46:02Z"
},
"name"
:
"Diaspora Client"
,
"name_with_namespace"
:
"Diaspora / Diaspora Client"
,
"path"
:
"diaspora-client"
,
"path_with_namespace"
:
"diaspora/diaspora-client"
,
"issues_enabled"
:
true
,
"open_issues_count"
:
1
,
"merge_requests_enabled"
:
true
,
"builds_enabled"
:
true
,
"wiki_enabled"
:
true
,
"snippets_enabled"
:
false
,
"container_registry_enabled"
:
false
,
"created_at"
:
"2013-09-30T13:46:02Z"
,
"last_activity_at"
:
"2013-09-30T13:46:02Z"
,
"creator_id"
:
3
,
"namespace"
:
{
"created_at"
:
"2013-09-30T13:46:02Z"
,
"description"
:
""
,
"id"
:
3
,
"name"
:
"Diaspora"
,
"owner_id"
:
1
,
"path"
:
"diaspora"
,
"updated_at"
:
"2013-09-30T13:46:02Z"
},
"archived"
:
false
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/4/uploads/avatar.png"
,
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
},
{
"id"
:
6
,
"description"
:
null
,
"default_branch"
:
"master"
,
"public"
:
false
,
"visibility_level"
:
0
,
"ssh_url_to_repo"
:
"git@example.com:brightbox/puppet.git"
,
"http_url_to_repo"
:
"http://example.com/brightbox/puppet.git"
,
"web_url"
:
"http://example.com/brightbox/puppet"
,
"tag_list"
:
[
"example"
,
"puppet"
],
"owner"
:
{
"id"
:
4
,
"name"
:
"Brightbox"
,
"created_at"
:
"2013-09-30T13:46:02Z"
},
"name"
:
"Puppet"
,
"name_with_namespace"
:
"Brightbox / Puppet"
,
"path"
:
"puppet"
,
"path_with_namespace"
:
"brightbox/puppet"
,
"issues_enabled"
:
true
,
"open_issues_count"
:
1
,
"merge_requests_enabled"
:
true
,
"builds_enabled"
:
true
,
"wiki_enabled"
:
true
,
"snippets_enabled"
:
false
,
"container_registry_enabled"
:
false
,
"created_at"
:
"2013-09-30T13:46:02Z"
,
"last_activity_at"
:
"2013-09-30T13:46:02Z"
,
"creator_id"
:
3
,
"namespace"
:
{
"created_at"
:
"2013-09-30T13:46:02Z"
,
"description"
:
""
,
"id"
:
4
,
"name"
:
"Brightbox"
,
"owner_id"
:
1
,
"path"
:
"brightbox"
,
"updated_at"
:
"2013-09-30T13:46:02Z"
},
"permissions"
:
{
"project_access"
:
{
"access_level"
:
10
,
"notification_level"
:
3
},
"group_access"
:
{
"access_level"
:
50
,
"notification_level"
:
3
}
},
"archived"
:
false
,
"avatar_url"
:
null
,
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
}
]
```
### List owned projects
Get a list of projects which are owned by the authenticated user.
...
...
lib/api/projects.rb
View file @
e956a24d
...
...
@@ -32,6 +32,21 @@ module API
end
end
# Get a list of visible projects for authenticated user
#
# Example Request:
# GET /projects/visible
get
'/visible'
do
@projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
@projects
=
filter_projects
(
@projects
)
@projects
=
paginate
@projects
if
params
[
:simple
]
present
@projects
,
with:
Entities
::
BasicProjectDetails
,
user:
current_user
else
present
@projects
,
with:
Entities
::
ProjectWithAccess
,
user:
current_user
end
end
# Get an owned projects list for authenticated user
#
# Example Request:
...
...
spec/requests/api/projects_spec.rb
View file @
e956a24d
...
...
@@ -175,6 +175,17 @@ describe API::API, api: true do
end
end
describe
'GET /projects/visible'
do
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
it
'returns the projects viewable by the user'
do
get
api
(
'/projects/visible'
,
user3
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
project
.
id
,
project2
.
id
,
project4
.
id
)
end
end
describe
'GET /projects/starred'
do
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
...
...
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