Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e6f34523
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e6f34523
编写于
7月 09, 2018
作者:
T
Tiago Botelho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adds with_projects optional parameter to /groups/:id API endpoint
上级
21a511e4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
5 deletion
+55
-5
changelogs/unreleased/42415-omit-projects-from-get-group-endpoint.yml
...nreleased/42415-omit-projects-from-get-group-endpoint.yml
+5
-0
doc/api/groups.md
doc/api/groups.md
+25
-0
lib/api/groups.rb
lib/api/groups.rb
+2
-1
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+23
-4
未找到文件。
changelogs/unreleased/42415-omit-projects-from-get-group-endpoint.yml
0 → 100644
浏览文件 @
e6f34523
---
title
:
Adds with_projects optional parameter to GET /groups/:id API endpoint
merge_request
:
20494
author
:
type
:
changed
doc/api/groups.md
浏览文件 @
e6f34523
...
...
@@ -210,6 +210,7 @@ Parameters:
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the group
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`with_custom_attributes`
| boolean | no | Include
[
custom attributes
](
custom_attributes.md
)
in response (admins only) |
|
`with_projects`
| boolean | no | Include details from projects that belong to the specified group (defaults to
`true`
). |
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/groups/4
...
...
@@ -361,6 +362,30 @@ Example response:
}
```
When adding the parameter
`with_projects=false`
, projects will not be returned.
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/groups/4?with_projects
=
false
```
Example response:
```
json
{
"id"
:
4
,
"name"
:
"Twitter"
,
"path"
:
"twitter"
,
"description"
:
"Aliquid qui quis dignissimos distinctio ut commodi voluptas est."
,
"visibility"
:
"public"
,
"avatar_url"
:
null
,
"web_url"
:
"https://gitlab.example.com/groups/twitter"
,
"request_access_enabled"
:
false
,
"full_name"
:
"Twitter"
,
"full_path"
:
"twitter"
,
"parent_id"
:
null
}
```
## New group
Creates a new project group. Available only for users who can create groups.
...
...
lib/api/groups.rb
浏览文件 @
e6f34523
...
...
@@ -150,12 +150,13 @@ module API
end
params
do
use
:with_custom_attributes
optional
:with_projects
,
type:
Boolean
,
default:
true
,
desc:
'Omit project details'
end
get
":id"
do
group
=
find_group!
(
params
[
:id
])
options
=
{
with:
Entities
::
GroupDetail
,
with:
params
[
:with_projects
]
?
Entities
::
GroupDetail
:
Entities
::
Group
,
current_user:
current_user
}
...
...
spec/requests/api/groups_spec.rb
浏览文件 @
e6f34523
...
...
@@ -251,14 +251,22 @@ describe API::Groups do
projects
end
def
response_project_ids
(
json_response
,
key
)
json_response
[
key
].
map
do
|
project
|
project
[
'id'
].
to_i
end
end
context
'when unauthenticated'
do
it
'returns 404 for a private group'
do
get
api
(
"/groups/
#{
group2
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'returns 200 for a public group'
do
get
api
(
"/groups/
#{
group1
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
...
...
@@ -268,7 +276,7 @@ describe API::Groups do
get
api
(
"/groups/
#{
public_group
.
id
}
"
)
expect
(
json_response
[
'projects'
].
map
{
|
p
|
p
[
'id'
].
to_i
}
)
expect
(
response_project_ids
(
json_response
,
'projects'
)
)
.
to
contain_exactly
(
projects
[
:public
].
id
)
end
...
...
@@ -278,7 +286,7 @@ describe API::Groups do
get
api
(
"/groups/
#{
group1
.
id
}
"
)
expect
(
json_response
[
'shared_projects'
].
map
{
|
p
|
p
[
'id'
].
to_i
}
)
expect
(
response_project_ids
(
json_response
,
'shared_projects'
)
)
.
to
contain_exactly
(
projects
[
:public
].
id
)
end
end
...
...
@@ -309,6 +317,17 @@ describe API::Groups do
expect
(
json_response
[
'shared_projects'
][
0
][
'id'
]).
to
eq
(
project
.
id
)
end
it
"returns one of user1's groups without projects when with_projects option is set to false"
do
project
=
create
(
:project
,
namespace:
group2
,
path:
'Foo'
)
create
(
:project_group_link
,
project:
project
,
group:
group1
)
get
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
with_projects:
false
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'projects'
]).
to
be_nil
expect
(
json_response
[
'shared_projects'
]).
to
be_nil
end
it
"does not return a non existing group"
do
get
api
(
"/groups/1328"
,
user1
)
...
...
@@ -327,7 +346,7 @@ describe API::Groups do
get
api
(
"/groups/
#{
public_group
.
id
}
"
,
user2
)
expect
(
json_response
[
'projects'
].
map
{
|
p
|
p
[
'id'
].
to_i
}
)
expect
(
response_project_ids
(
json_response
,
'projects'
)
)
.
to
contain_exactly
(
projects
[
:public
].
id
,
projects
[
:internal
].
id
)
end
...
...
@@ -337,7 +356,7 @@ describe API::Groups do
get
api
(
"/groups/
#{
group1
.
id
}
"
,
user2
)
expect
(
json_response
[
'shared_projects'
].
map
{
|
p
|
p
[
'id'
].
to_i
}
)
expect
(
response_project_ids
(
json_response
,
'shared_projects'
)
)
.
to
contain_exactly
(
projects
[
:public
].
id
,
projects
[
:internal
].
id
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录