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
3b5a90bd
Commit
3b5a90bd
authored
Sep 08, 2012
by
miks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Projects hooks API implemented
parent
27e44365
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
0 deletions
+119
-0
doc/api/projects.md
doc/api/projects.md
+44
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/projects.rb
lib/api/projects.rb
+40
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+31
-0
No files found.
doc/api/projects.md
View file @
3b5a90bd
...
@@ -173,6 +173,50 @@ Parameters:
...
@@ -173,6 +173,50 @@ Parameters:
Will return status `
200 OK
` on success, or `
404 Not found
` on fail.
Will return status `
200 OK
` on success, or `
404 Not found
` on fail.
## Get project hooks
Get hooks for project
```
GET /projects/:id/hooks
```
Parameters:
+ `
id
` (required) - The ID or code name of a project
Will return hooks with status `
200 OK
` on success, or `
404 Not found
` on fail.
## Add project hook
Add hook to project
```
POST /projects/:id/hooks
```
Parameters:
+ `
id
` (required) - The ID or code name of a project
+ `
url
` (required) - The hook URL
Will return status `
201 Created
` on success, or `
404 Not found
` on fail.
## Delete project hook
Delete hook from project
```
DELETE /projects/:id/hooks
```
Parameters:
+ `
id
` (required) - The ID or code name of a project
+ `
hook_id
` (required) - The ID of hook to delete
Will return status `
200 OK
` on success, or `
404 Not found
` on fail.
## Project repository branches
## Project repository branches
Get a list of repository branches from a project, sorted by name alphabetically.
Get a list of repository branches from a project, sorted by name alphabetically.
...
...
lib/api/entities.rb
View file @
3b5a90bd
...
@@ -9,6 +9,10 @@ module Gitlab
...
@@ -9,6 +9,10 @@ module Gitlab
expose
:id
,
:email
,
:name
,
:blocked
,
:created_at
expose
:id
,
:email
,
:name
,
:blocked
,
:created_at
end
end
class
Hook
<
Grape
::
Entity
expose
:id
,
:url
end
class
Project
<
Grape
::
Entity
class
Project
<
Grape
::
Entity
expose
:id
,
:code
,
:name
,
:description
,
:path
,
:default_branch
expose
:id
,
:code
,
:name
,
:description
,
:path
,
:default_branch
expose
:owner
,
using:
Entities
::
UserBasic
expose
:owner
,
using:
Entities
::
UserBasic
...
...
lib/api/projects.rb
View file @
3b5a90bd
...
@@ -103,6 +103,46 @@ module Gitlab
...
@@ -103,6 +103,46 @@ module Gitlab
nil
nil
end
end
# Get project hooks
#
# Parameters:
# id (required) - The ID or code name of a project
# Example Request:
# GET /projects/:id/hooks
get
":id/hooks"
do
@hooks
=
paginate
user_project
.
hooks
present
@hooks
,
with:
Entities
::
Hook
end
# Add hook to project
#
# Parameters:
# id (required) - The ID or code name of a project
# url (required) - The hook URL
# Example Request:
# POST /projects/:id/hooks
post
":id/hooks"
do
@hook
=
user_project
.
hooks
.
new
({
"url"
=>
params
[
:url
]})
if
@hook
.
save
present
@hook
,
with:
Entities
::
Hook
else
error!
({
'message'
=>
'404 Not found'
},
404
)
end
end
# Delete project hook
#
# Parameters:
# id (required) - The ID or code name of a project
# hook_id (required) - The ID of hook to delete
# Example Request:
# DELETE /projects/:id/hooks
delete
":id/hooks"
do
@hook
=
user_project
.
hooks
.
find
(
params
[
:hook_id
])
@hook
.
destroy
nil
end
# Get a project repository branches
# Get a project repository branches
#
#
# Parameters:
# Parameters:
...
...
spec/requests/api/projects_spec.rb
View file @
3b5a90bd
...
@@ -6,6 +6,7 @@ describe Gitlab::API do
...
@@ -6,6 +6,7 @@ describe Gitlab::API do
let
(
:user
)
{
Factory
:user
}
let
(
:user
)
{
Factory
:user
}
let
(
:user2
)
{
Factory
.
create
(
:user
)
}
let
(
:user2
)
{
Factory
.
create
(
:user
)
}
let
(
:user3
)
{
Factory
.
create
(
:user
)
}
let
(
:user3
)
{
Factory
.
create
(
:user
)
}
let!
(
:hook
)
{
Factory
:project_hook
,
project:
project
,
url:
"http://example.com"
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:snippet
)
{
Factory
:snippet
,
author:
user
,
project:
project
,
title:
'example'
}
let!
(
:snippet
)
{
Factory
:snippet
,
author:
user
,
project:
project
,
title:
'example'
}
let!
(
:users_project
)
{
Factory
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
}
let!
(
:users_project
)
{
Factory
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
}
...
@@ -147,6 +148,36 @@ describe Gitlab::API do
...
@@ -147,6 +148,36 @@ describe Gitlab::API do
end
end
end
end
describe
"GET /projects/:id/hooks"
do
it
"should return project hooks"
do
get
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
count
.
should
==
1
json_response
.
first
[
'url'
].
should
==
"http://example.com"
end
end
describe
"POST /projects/:id/users"
do
it
"should add hook to project"
do
expect
{
post
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
"url"
=>
"http://example.com"
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
end
end
describe
"DELETE /projects/:id/hooks"
do
it
"should delete hook from project"
do
expect
{
delete
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
hook_id:
hook
.
id
}.
to
change
{
project
.
hooks
.
count
}.
by
(
-
1
)
end
end
describe
"GET /projects/:id/repository/tags"
do
describe
"GET /projects/:id/repository/tags"
do
it
"should return an array of project tags"
do
it
"should return an array of project tags"
do
get
api
(
"/projects/
#{
project
.
code
}
/repository/tags"
,
user
)
get
api
(
"/projects/
#{
project
.
code
}
/repository/tags"
,
user
)
...
...
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