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
a0f9e4d6
Commit
a0f9e4d6
authored
Jun 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add members_count and parent_id info on /namespaces API
parent
9c50fa7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
doc/api/namespaces.md
doc/api/namespaces.md
+12
-1
lib/api/entities.rb
lib/api/entities.rb
+5
-0
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+16
-0
No files found.
doc/api/namespaces.md
View file @
a0f9e4d6
...
...
@@ -29,18 +29,27 @@ Example response:
{
"id"
:
1
,
"path"
:
"user1"
,
"kind"
:
"user"
"kind"
:
"user"
,
"full_path"
:
"user1"
,
"parent_id"
:
"null"
,
"members_count"
:
"null"
},
{
"id"
:
2
,
"path"
:
"group1"
,
"kind"
:
"group"
"full_path"
:
"group1"
,
"parent_id"
:
"null"
,
"members_count"
:
2
},
{
"id"
:
3
,
"path"
:
"bar"
,
"kind"
:
"group"
,
"full_path"
:
"foo/bar"
,
"parent_id"
:
"9"
,
"members_count"
:
5
},
}
]
```
...
...
@@ -72,6 +81,8 @@ Example response:
"path"
:
"twitter"
,
"kind"
:
"group"
,
"full_path"
:
"twitter"
,
"parent_id"
:
"null"
,
"members_count"
:
2
}
]
```
lib/api/entities.rb
View file @
a0f9e4d6
...
...
@@ -513,6 +513,11 @@ module API
expose
:id
,
:name
,
:path
,
:kind
,
:full_path
# EE-only
expose
:parent_id
expose
:members_count
do
|
namespace
,
_
|
namespace
.
users_with_descendants
.
count
if
namespace
.
kind
==
'group'
end
expose
:shared_runners_minutes_limit
,
if:
lambda
{
|
_
,
options
|
options
[
:current_user
]
&
.
admin?
}
expose
:plan
,
if:
lambda
{
|
_
,
options
|
options
[
:current_user
]
&
.
admin?
}
end
...
...
spec/requests/api/namespaces_spec.rb
View file @
a0f9e4d6
...
...
@@ -15,6 +15,14 @@ describe API::Namespaces do
end
context
"when authenticated as admin"
do
it
"returns correct attributes"
do
get
api
(
"/namespaces"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
first
).
to
include
(
'id'
,
'name'
,
'path'
,
'full_path'
,
'parent_id'
,
'members_count'
)
end
it
"admin: returns an array of all namespaces"
do
get
api
(
"/namespaces"
,
admin
)
...
...
@@ -37,6 +45,14 @@ describe API::Namespaces do
end
context
"when authenticated as a regular user"
do
it
"returns correct attributes"
do
get
api
(
"/namespaces"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
first
).
to
include
(
'id'
,
'name'
,
'path'
,
'full_path'
,
'parent_id'
,
'members_count'
)
end
it
"user: returns an array of namespaces"
do
get
api
(
"/namespaces"
,
user
)
...
...
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