Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8d1ab256
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,发现更多精彩内容 >>
提交
8d1ab256
编写于
8月 21, 2017
作者:
T
Travis Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add pages domains API implementation
上级
bcccf6c1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
122 addition
and
0 deletion
+122
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
lib/api/pages_domains.rb
lib/api/pages_domains.rb
+117
-0
未找到文件。
lib/api/api.rb
浏览文件 @
8d1ab256
...
...
@@ -131,6 +131,7 @@ module API
mount
::
API
::
Namespaces
mount
::
API
::
Notes
mount
::
API
::
NotificationSettings
mount
::
API
::
PagesDomains
mount
::
API
::
Pipelines
mount
::
API
::
PipelineSchedules
mount
::
API
::
ProjectHooks
...
...
lib/api/helpers.rb
浏览文件 @
8d1ab256
...
...
@@ -184,6 +184,10 @@ module API
end
end
def
require_pages_enabled!
not_found!
unless
user_project
.
pages_available?
end
def
can?
(
object
,
action
,
subject
=
:global
)
Ability
.
allowed?
(
object
,
action
,
subject
)
end
...
...
lib/api/pages_domains.rb
0 → 100644
浏览文件 @
8d1ab256
module
API
class
PagesDomains
<
Grape
::
API
include
PaginationParams
before
do
authenticate!
require_pages_enabled!
end
after_validation
do
normalize_params_file_to_string
end
helpers
do
def
find_pages_domain!
user_project
.
pages_domains
.
find_by
(
domain:
params
[
:domain
])
||
not_found!
(
'PagesDomain'
)
end
def
pages_domain
@pages_domain
||=
find_pages_domain!
end
def
normalize_params_file_to_string
params
.
each
do
|
k
,
v
|
if
v
.
is_a?
(
Hash
)
&&
v
.
key?
(
:tempfile
)
params
[
k
]
=
v
[
:tempfile
].
to_a
.
join
(
''
)
end
end
end
end
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get all pages domains'
do
success
Entities
::
PagesDomain
end
params
do
use
:pagination
end
get
":id/pages/domains"
do
authorize!
:read_pages
,
user_project
present
paginate
(
user_project
.
pages_domains
.
order
(
:domain
)),
with:
Entities
::
PagesDomain
end
desc
'Get a single pages domain'
do
success
Entities
::
PagesDomain
end
params
do
requires
:domain
,
type:
String
,
desc:
'The domain'
end
get
":id/pages/domains/:domain"
,
requirements:
{
domain:
%r{[^/]+}
}
do
authorize!
:read_pages
,
user_project
present
pages_domain
,
with:
Entities
::
PagesDomain
end
desc
'Create a new pages domain'
do
success
Entities
::
PagesDomain
end
params
do
requires
:domain
,
type:
String
,
desc:
'The domain'
optional
:certificate
,
allow_blank:
false
,
types:
[
File
,
String
],
desc:
'The certificate'
optional
:key
,
allow_blank:
false
,
types:
[
File
,
String
],
desc:
'The key'
all_or_none_of
:certificate
,
:key
end
post
":id/pages/domains"
do
authorize!
:update_pages
,
user_project
pages_domain_params
=
declared
(
params
,
include_parent_namespaces:
false
)
pages_domain
=
user_project
.
pages_domains
.
create
(
pages_domain_params
)
if
pages_domain
.
persisted?
present
pages_domain
,
with:
Entities
::
PagesDomain
else
render_validation_error!
(
pages_domain
)
end
end
desc
'Updates a pages domain'
params
do
requires
:domain
,
type:
String
,
desc:
'The domain'
optional
:certificate
,
allow_blank:
false
,
types:
[
File
,
String
],
desc:
'The certificate'
optional
:key
,
allow_blank:
false
,
types:
[
File
,
String
],
desc:
'The key'
end
put
":id/pages/domains/:domain"
,
requirements:
{
domain:
%r{[^/]+}
}
do
authorize!
:update_pages
,
user_project
pages_domain_params
=
declared
(
params
,
include_parent_namespaces:
false
)
# Remove empty private key if certificate is not empty.
if
pages_domain_params
[
:certificate
]
&&
!
pages_domain_params
[
:key
]
pages_domain_params
.
delete
(
:key
)
end
if
pages_domain
.
update
(
pages_domain_params
)
present
pages_domain
,
with:
Entities
::
PagesDomain
else
render_validation_error!
(
pages_domain
)
end
end
desc
'Delete a pages domain'
params
do
requires
:domain
,
type:
String
,
desc:
'The domain'
end
delete
":id/pages/domains/:domain"
,
requirements:
{
domain:
%r{[^/]+}
}
do
authorize!
:update_pages
,
user_project
status
204
pages_domain
.
destroy
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录