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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
89a349f9
Commit
89a349f9
authored
12 years ago
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1685 from jozefvaclavik/master
Hooks API (List one hook & edit)
parents
3950b8e8
96abbf02
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
4 deletions
+90
-4
CHANGELOG
CHANGELOG
+2
-0
doc/api/projects.md
doc/api/projects.md
+34
-2
lib/api/projects.rb
lib/api/projects.rb
+34
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+20
-2
No files found.
CHANGELOG
View file @
89a349f9
master
master
- [API] list one project hook
- [API] edit project hook
- [API] add project snippets list
- [API] add project snippets list
- [API] allow to authorize using private token in HTTP header
- [API] allow to authorize using private token in HTTP header
- [API] add user creation
- [API] add user creation
...
...
This diff is collapsed.
Click to expand it.
doc/api/projects.md
View file @
89a349f9
...
@@ -196,9 +196,9 @@ Parameters:
...
@@ -196,9 +196,9 @@ Parameters:
Status code
`200`
will be returned on success.
Status code
`200`
will be returned on success.
##
Ge
t project hooks
##
Lis
t project hooks
Get
hooks for project
Get
list for project hooks
```
```
GET /projects/:id/hooks
GET /projects/:id/hooks
...
@@ -210,6 +210,21 @@ Parameters:
...
@@ -210,6 +210,21 @@ Parameters:
Will return hooks with status
`200 OK`
on success, or
`404 Not found`
on fail.
Will return hooks with status
`200 OK`
on success, or
`404 Not found`
on fail.
## Get project hook
Get hook for project
```
GET /projects/:id/hooks/:hook_id
```
Parameters:
+
`id`
(required) - The ID or code name of a project
+
`hook_id`
(required) - The ID of a project hook
Will return hook with status
`200 OK`
on success, or
`404 Not found`
on fail.
## Add project hook
## Add project hook
Add hook to project
Add hook to project
...
@@ -225,6 +240,23 @@ Parameters:
...
@@ -225,6 +240,23 @@ Parameters:
Will return status
`201 Created`
on success, or
`404 Not found`
on fail.
Will return status
`201 Created`
on success, or
`404 Not found`
on fail.
## Edit project hook
Edit hook for project
```
PUT /projects/:id/hooks/:hook_id
```
Parameters:
+
`id`
(required) - The ID or code name of a project
+
`hook_id`
(required) - The ID of a project hook
+
`url`
(required) - The hook URL
Will return status
`201 Created`
on success, or
`404 Not found`
on fail.
## Delete project hook
## Delete project hook
Delete hook from project
Delete hook from project
...
...
This diff is collapsed.
Click to expand it.
lib/api/projects.rb
View file @
89a349f9
...
@@ -147,6 +147,19 @@ module Gitlab
...
@@ -147,6 +147,19 @@ module Gitlab
@hooks
=
paginate
user_project
.
hooks
@hooks
=
paginate
user_project
.
hooks
present
@hooks
,
with:
Entities
::
Hook
present
@hooks
,
with:
Entities
::
Hook
end
end
# Get a project hook
#
# Parameters:
# id (required) - The ID or code name of a project
# hook_id (required) - The ID of a project hook
# Example Request:
# GET /projects/:id/hooks/:hook_id
get
":id/hooks/:hook_id"
do
@hook
=
user_project
.
hooks
.
find
(
params
[
:hook_id
])
present
@hook
,
with:
Entities
::
Hook
end
# Add hook to project
# Add hook to project
#
#
...
@@ -164,6 +177,27 @@ module Gitlab
...
@@ -164,6 +177,27 @@ module Gitlab
error!
({
'message'
=>
'404 Not found'
},
404
)
error!
({
'message'
=>
'404 Not found'
},
404
)
end
end
end
end
# Update an existing project hook
#
# Parameters:
# id (required) - The ID or code name of a project
# hook_id (required) - The ID of a project hook
# url (required) - The hook URL
# Example Request:
# PUT /projects/:id/hooks/:hook_id
put
":id/hooks/:hook_id"
do
@hook
=
user_project
.
hooks
.
find
(
params
[
:hook_id
])
authorize!
:admin_project
,
user_project
attrs
=
attributes_for_keys
[
:url
]
if
@hook
.
update_attributes
attrs
present
@hook
,
with:
Entities
::
Hook
else
not_found!
end
end
# Delete project hook
# Delete project hook
#
#
...
...
This diff is collapsed.
Click to expand it.
spec/requests/api/projects_spec.rb
View file @
89a349f9
...
@@ -172,7 +172,15 @@ describe Gitlab::API do
...
@@ -172,7 +172,15 @@ describe Gitlab::API do
end
end
end
end
describe
"POST /projects/:id/users"
do
describe
"GET /projects/:id/hooks/:hook_id"
do
it
"should return a project hook"
do
get
api
(
"/projects/
#{
project
.
code
}
/hooks/
#{
hook
.
id
}
"
,
user
)
response
.
status
.
should
==
200
json_response
[
'url'
].
should
==
hook
.
url
end
end
describe
"POST /projects/:id/hooks"
do
it
"should add hook to project"
do
it
"should add hook to project"
do
expect
{
expect
{
post
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
post
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
...
@@ -180,6 +188,16 @@ describe Gitlab::API do
...
@@ -180,6 +188,16 @@ describe Gitlab::API do
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
end
end
end
end
describe
"PUT /projects/:id/hooks/:hook_id"
do
it
"should update an existing project hook"
do
put
api
(
"/projects/
#{
project
.
code
}
/hooks/
#{
hook
.
id
}
"
,
user
),
url:
'http://example.com'
response
.
status
.
should
==
200
json_response
[
'url'
].
should
==
'http://example.com'
end
end
describe
"DELETE /projects/:id/hooks"
do
describe
"DELETE /projects/:id/hooks"
do
it
"should delete hook from project"
do
it
"should delete hook from project"
do
...
@@ -246,7 +264,7 @@ describe Gitlab::API do
...
@@ -246,7 +264,7 @@ describe Gitlab::API do
end
end
end
end
describe
"PUT /projects/:id/snippets"
do
describe
"PUT /projects/:id/snippets
/:shippet_id
"
do
it
"should update an existing project snippet"
do
it
"should update an existing project snippet"
do
put
api
(
"/projects/
#{
project
.
code
}
/snippets/
#{
snippet
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
code
}
/snippets/
#{
snippet
.
id
}
"
,
user
),
code:
'updated code'
code:
'updated code'
...
...
This diff is collapsed.
Click to expand it.
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