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
8d1ab256
Commit
8d1ab256
authored
Aug 21, 2017
by
Travis Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pages domains API implementation
parent
bcccf6c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
0 deletions
+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
No files found.
lib/api/api.rb
View file @
8d1ab256
...
@@ -131,6 +131,7 @@ module API
...
@@ -131,6 +131,7 @@ module API
mount
::
API
::
Namespaces
mount
::
API
::
Namespaces
mount
::
API
::
Notes
mount
::
API
::
Notes
mount
::
API
::
NotificationSettings
mount
::
API
::
NotificationSettings
mount
::
API
::
PagesDomains
mount
::
API
::
Pipelines
mount
::
API
::
Pipelines
mount
::
API
::
PipelineSchedules
mount
::
API
::
PipelineSchedules
mount
::
API
::
ProjectHooks
mount
::
API
::
ProjectHooks
...
...
lib/api/helpers.rb
View file @
8d1ab256
...
@@ -184,6 +184,10 @@ module API
...
@@ -184,6 +184,10 @@ module API
end
end
end
end
def
require_pages_enabled!
not_found!
unless
user_project
.
pages_available?
end
def
can?
(
object
,
action
,
subject
=
:global
)
def
can?
(
object
,
action
,
subject
=
:global
)
Ability
.
allowed?
(
object
,
action
,
subject
)
Ability
.
allowed?
(
object
,
action
,
subject
)
end
end
...
...
lib/api/pages_domains.rb
0 → 100644
View file @
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
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