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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
e836b904
Commit
e836b904
authored
Oct 13, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify system hooks API
parent
4b889dbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
31 deletions
+29
-31
lib/api/system_hooks.rb
lib/api/system_hooks.rb
+29
-31
No files found.
lib/api/system_hooks.rb
View file @
e836b904
...
@@ -7,38 +7,36 @@ module API
...
@@ -7,38 +7,36 @@ module API
end
end
resource
:hooks
do
resource
:hooks
do
# Get the list of system hooks
desc
'Get the list of system hooks'
do
#
success
Entities
::
Hook
# Example Request:
end
# GET /hooks
get
do
get
do
@
hooks
=
SystemHook
.
all
hooks
=
SystemHook
.
all
present
@
hooks
,
with:
Entities
::
Hook
present
hooks
,
with:
Entities
::
Hook
end
end
# Create new system hook
desc
'Create a new system hook'
do
#
success
Entities
::
Hook
# Parameters:
end
# url (required) - url for system hook
params
do
# Example Request
requires
:url
,
type:
String
,
desc:
'The URL for the system hook'
# POST /hooks
end
post
do
post
do
attrs
=
attributes_for_keys
[
:url
]
hook
=
SystemHook
.
new
declared
(
params
).
to_h
required_attributes!
[
:url
]
@hook
=
SystemHook
.
new
attrs
if
hook
.
save
if
@hook
.
save
present
hook
,
with:
Entities
::
Hook
present
@hook
,
with:
Entities
::
Hook
else
else
not_found!
not_found!
end
end
end
end
# Test a hook
desc
'Test a hook'
#
params
do
# Example Request
requires
:id
,
type:
Integer
,
desc:
'The ID of the system hook'
# GET /hooks/:i
d
en
d
get
":id"
do
get
":id"
do
@
hook
=
SystemHook
.
find
(
params
[
:id
])
hook
=
SystemHook
.
find
(
params
[
:id
])
data
=
{
data
=
{
event_name:
"project_create"
,
event_name:
"project_create"
,
name:
"Ruby"
,
name:
"Ruby"
,
...
@@ -47,20 +45,20 @@ module API
...
@@ -47,20 +45,20 @@ module API
owner_name:
"Someone"
,
owner_name:
"Someone"
,
owner_email:
"example@gitlabhq.com"
owner_email:
"example@gitlabhq.com"
}
}
@
hook
.
execute
(
data
,
'system_hooks'
)
hook
.
execute
(
data
,
'system_hooks'
)
data
data
end
end
# Delete a hook. This is an idempotent function.
desc
'Delete a hook'
do
#
success
Entities
::
Hook
# Parameters:
end
# id (required) - ID of the hook
params
do
# Example Request:
requires
:id
,
type:
Integer
,
desc:
'The ID of the system hook'
# DELETE /hooks/:i
d
en
d
delete
":id"
do
delete
":id"
do
begin
begin
@
hook
=
SystemHook
.
find
(
params
[
:id
])
hook
=
SystemHook
.
find
(
params
[
:id
])
@hook
.
destroy
present
hook
.
destroy
,
with:
Entities
::
Hook
rescue
rescue
# SystemHook raises an Error if no hook with id found
# SystemHook raises an Error if no hook with id found
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