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
Léo-Paul Géneau
gitlab-ce
Commits
f9c6d8a4
Commit
f9c6d8a4
authored
Jul 25, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1142 from NARKOZ/api
API changes
parents
92d98f5a
cb32e032
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
32 deletions
+55
-32
doc/api/issues.md
doc/api/issues.md
+8
-5
doc/api/projects.md
doc/api/projects.md
+11
-11
lib/api/entities.rb
lib/api/entities.rb
+3
-1
lib/api/helpers.rb
lib/api/helpers.rb
+7
-1
lib/api/issues.rb
lib/api/issues.rb
+5
-5
lib/api/projects.rb
lib/api/projects.rb
+8
-8
spec/api/projects_spec.rb
spec/api/projects_spec.rb
+13
-1
No files found.
doc/api/issues.md
View file @
f9c6d8a4
...
@@ -10,6 +10,7 @@ GET /issues
...
@@ -10,6 +10,7 @@ GET /issues
[
[
{
{
"id"
:
43
,
"id"
:
43
,
"project_id"
:
8
,
"title"
:
"4xx/5xx pages"
,
"title"
:
"4xx/5xx pages"
,
"description"
:
""
,
"description"
:
""
,
"labels"
:
[
],
"labels"
:
[
],
...
@@ -28,6 +29,7 @@ GET /issues
...
@@ -28,6 +29,7 @@ GET /issues
},
},
{
{
"id"
:
42
,
"id"
:
42
,
"project_id"
:
8
,
"title"
:
"Add user settings"
,
"title"
:
"Add user settings"
,
"description"
:
""
,
"description"
:
""
,
"labels"
:
[
"labels"
:
[
...
@@ -73,7 +75,7 @@ GET /projects/:id/issues
...
@@ -73,7 +75,7 @@ GET /projects/:id/issues
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
## Single issue
## Single issue
...
@@ -85,12 +87,13 @@ GET /projects/:id/issues/:issue_id
...
@@ -85,12 +87,13 @@ GET /projects/:id/issues/:issue_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`issue_id`
(required) - The ID of a project issue
+
`issue_id`
(required) - The ID of a project issue
```
json
```
json
{
{
"id"
:
42
,
"id"
:
42
,
"project_id"
:
8
,
"title"
:
"Add user settings"
,
"title"
:
"Add user settings"
,
"description"
:
""
,
"description"
:
""
,
"labels"
:
[
"labels"
:
[
...
@@ -135,7 +138,7 @@ POST /projects/:id/issues
...
@@ -135,7 +138,7 @@ POST /projects/:id/issues
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`title`
(required) - The title of an issue
+
`title`
(required) - The title of an issue
+
`description`
(optional) - The description of an issue
+
`description`
(optional) - The description of an issue
+
`assignee_id`
(optional) - The ID of a user to assign issue
+
`assignee_id`
(optional) - The ID of a user to assign issue
...
@@ -154,7 +157,7 @@ PUT /projects/:id/issues/:issue_id
...
@@ -154,7 +157,7 @@ PUT /projects/:id/issues/:issue_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`issue_id`
(required) - The ID of a project's issue
+
`issue_id`
(required) - The ID of a project's issue
+
`title`
(optional) - The title of an issue
+
`title`
(optional) - The title of an issue
+
`description`
(optional) - The description of an issue
+
`description`
(optional) - The description of an issue
...
@@ -175,7 +178,7 @@ DELETE /projects/:id/issues/:issue_id
...
@@ -175,7 +178,7 @@ DELETE /projects/:id/issues/:issue_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`issue_id`
(required) - The ID of a project's issue
+
`issue_id`
(required) - The ID of a project's issue
Status code
`200`
will be returned on success.
Status code
`200`
will be returned on success.
doc/api/projects.md
View file @
f9c6d8a4
## List projects
## List projects
Get a list of authenticated user
s'
projects.
Get a list of authenticated user
's
projects.
```
```
GET /projects
GET /projects
...
@@ -63,7 +63,7 @@ GET /projects/:id
...
@@ -63,7 +63,7 @@ GET /projects/:id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
```
json
```
json
{
{
...
@@ -91,7 +91,7 @@ Parameters:
...
@@ -91,7 +91,7 @@ Parameters:
## Project repository branches
## Project repository branches
Get a list of project repository branches.
Get a list of project repository branches
sorted by name alphabetically
.
```
```
GET /projects/:id/repository/branches
GET /projects/:id/repository/branches
...
@@ -99,7 +99,7 @@ GET /projects/:id/repository/branches
...
@@ -99,7 +99,7 @@ GET /projects/:id/repository/branches
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
```
json
```
json
[
[
...
@@ -131,7 +131,7 @@ Parameters:
...
@@ -131,7 +131,7 @@ Parameters:
## Project repository tags
## Project repository tags
Get a list of project repository tags.
Get a list of project repository tags
sorted by name in reverse alphabetical order
.
```
```
GET /projects/:id/repository/tags
GET /projects/:id/repository/tags
...
@@ -139,7 +139,7 @@ GET /projects/:id/repository/tags
...
@@ -139,7 +139,7 @@ GET /projects/:id/repository/tags
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
```
json
```
json
[
[
...
@@ -183,7 +183,7 @@ GET /projects/:id/snippets/:snippet_id
...
@@ -183,7 +183,7 @@ GET /projects/:id/snippets/:snippet_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`snippet_id`
(required) - The ID of a project's snippet
+
`snippet_id`
(required) - The ID of a project's snippet
```
json
```
json
...
@@ -214,7 +214,7 @@ GET /projects/:id/snippets/:snippet_id/raw
...
@@ -214,7 +214,7 @@ GET /projects/:id/snippets/:snippet_id/raw
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`snippet_id`
(required) - The ID of a project's snippet
+
`snippet_id`
(required) - The ID of a project's snippet
## New snippet
## New snippet
...
@@ -227,7 +227,7 @@ POST /projects/:id/snippets
...
@@ -227,7 +227,7 @@ POST /projects/:id/snippets
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`title`
(required) - The title of a snippet
+
`title`
(required) - The title of a snippet
+
`file_name`
(required) - The name of a snippet file
+
`file_name`
(required) - The name of a snippet file
+
`lifetime`
(optional) - The expiration date of a snippet
+
`lifetime`
(optional) - The expiration date of a snippet
...
@@ -245,7 +245,7 @@ PUT /projects/:id/snippets/:snippet_id
...
@@ -245,7 +245,7 @@ PUT /projects/:id/snippets/:snippet_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`snippet_id`
(required) - The ID of a project's snippet
+
`snippet_id`
(required) - The ID of a project's snippet
+
`title`
(optional) - The title of a snippet
+
`title`
(optional) - The title of a snippet
+
`file_name`
(optional) - The name of a snippet file
+
`file_name`
(optional) - The name of a snippet file
...
@@ -264,7 +264,7 @@ DELETE /projects/:id/snippets/:snippet_id
...
@@ -264,7 +264,7 @@ DELETE /projects/:id/snippets/:snippet_id
Parameters:
Parameters:
+
`id`
(required) - The code name of a project
+
`id`
(required) - The
ID or
code name of a project
+
`snippet_id`
(required) - The ID of a project's snippet
+
`snippet_id`
(required) - The ID of a project's snippet
Status code
`200`
will be returned on success.
Status code
`200`
will be returned on success.
lib/api/entities.rb
View file @
f9c6d8a4
...
@@ -31,7 +31,9 @@ module Gitlab
...
@@ -31,7 +31,9 @@ module Gitlab
end
end
class
Issue
<
Grape
::
Entity
class
Issue
<
Grape
::
Entity
expose
:id
,
:title
,
:description
expose
:id
expose
(
:project_id
)
{
|
issue
|
issue
.
project
.
id
}
expose
:title
,
:description
expose
:label_list
,
:as
=>
:labels
expose
:label_list
,
:as
=>
:labels
expose
:milestone
,
:using
=>
Entities
::
Milestone
expose
:milestone
,
:using
=>
Entities
::
Milestone
expose
:assignee
,
:author
,
:using
=>
Entities
::
UserBasic
expose
:assignee
,
:author
,
:using
=>
Entities
::
UserBasic
...
...
lib/api/helpers.rb
View file @
f9c6d8a4
...
@@ -5,7 +5,13 @@ module Gitlab
...
@@ -5,7 +5,13 @@ module Gitlab
end
end
def
user_project
def
user_project
@project
||=
current_user
.
projects
.
find_by_code
(
params
[
:id
])
if
@project
||=
current_user
.
projects
.
find_by_id
(
params
[
:id
])
||
current_user
.
projects
.
find_by_code
(
params
[
:id
])
else
error!
({
'message'
=>
'404 Not found'
},
404
)
end
@project
end
end
def
authenticate!
def
authenticate!
...
...
lib/api/issues.rb
View file @
f9c6d8a4
...
@@ -17,7 +17,7 @@ module Gitlab
...
@@ -17,7 +17,7 @@ module Gitlab
# Get a list of project issues
# Get a list of project issues
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# Example Request:
# Example Request:
# GET /projects/:id/issues
# GET /projects/:id/issues
get
":id/issues"
do
get
":id/issues"
do
...
@@ -27,7 +27,7 @@ module Gitlab
...
@@ -27,7 +27,7 @@ module Gitlab
# Get a single project issue
# Get a single project issue
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# issue_id (required) - The ID of a project issue
# issue_id (required) - The ID of a project issue
# Example Request:
# Example Request:
# GET /projects/:id/issues/:issue_id
# GET /projects/:id/issues/:issue_id
...
@@ -39,7 +39,7 @@ module Gitlab
...
@@ -39,7 +39,7 @@ module Gitlab
# Create a new project issue
# Create a new project issue
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# title (required) - The title of an issue
# title (required) - The title of an issue
# description (optional) - The description of an issue
# description (optional) - The description of an issue
# assignee_id (optional) - The ID of a user to assign issue
# assignee_id (optional) - The ID of a user to assign issue
...
@@ -67,7 +67,7 @@ module Gitlab
...
@@ -67,7 +67,7 @@ module Gitlab
# Update an existing issue
# Update an existing issue
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# issue_id (required) - The ID of a project issue
# issue_id (required) - The ID of a project issue
# title (optional) - The title of an issue
# title (optional) - The title of an issue
# description (optional) - The description of an issue
# description (optional) - The description of an issue
...
@@ -98,7 +98,7 @@ module Gitlab
...
@@ -98,7 +98,7 @@ module Gitlab
# Delete a project issue
# Delete a project issue
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# issue_id (required) - The ID of a project issue
# issue_id (required) - The ID of a project issue
# Example Request:
# Example Request:
# DELETE /projects/:id/issues/:issue_id
# DELETE /projects/:id/issues/:issue_id
...
...
lib/api/projects.rb
View file @
f9c6d8a4
...
@@ -16,7 +16,7 @@ module Gitlab
...
@@ -16,7 +16,7 @@ module Gitlab
# Get a single project
# Get a single project
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# Example Request:
# Example Request:
# GET /projects/:id
# GET /projects/:id
get
":id"
do
get
":id"
do
...
@@ -26,7 +26,7 @@ module Gitlab
...
@@ -26,7 +26,7 @@ module Gitlab
# Get a project repository branches
# Get a project repository branches
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# Example Request:
# Example Request:
# GET /projects/:id/repository/branches
# GET /projects/:id/repository/branches
get
":id/repository/branches"
do
get
":id/repository/branches"
do
...
@@ -36,7 +36,7 @@ module Gitlab
...
@@ -36,7 +36,7 @@ module Gitlab
# Get a project repository tags
# Get a project repository tags
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# Example Request:
# Example Request:
# GET /projects/:id/repository/tags
# GET /projects/:id/repository/tags
get
":id/repository/tags"
do
get
":id/repository/tags"
do
...
@@ -46,7 +46,7 @@ module Gitlab
...
@@ -46,7 +46,7 @@ module Gitlab
# Get a project snippet
# Get a project snippet
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# snippet_id (required) - The ID of a project snippet
# snippet_id (required) - The ID of a project snippet
# Example Request:
# Example Request:
# GET /projects/:id/snippets/:snippet_id
# GET /projects/:id/snippets/:snippet_id
...
@@ -58,7 +58,7 @@ module Gitlab
...
@@ -58,7 +58,7 @@ module Gitlab
# Create a new project snippet
# Create a new project snippet
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# title (required) - The title of a snippet
# title (required) - The title of a snippet
# file_name (required) - The name of a snippet file
# file_name (required) - The name of a snippet file
# lifetime (optional) - The expiration date of a snippet
# lifetime (optional) - The expiration date of a snippet
...
@@ -84,7 +84,7 @@ module Gitlab
...
@@ -84,7 +84,7 @@ module Gitlab
# Update an existing project snippet
# Update an existing project snippet
#
#
# Parameters:
# Parameters:
# id (required) - The code name of a project
# id (required) - The
ID or
code name of a project
# snippet_id (required) - The ID of a project snippet
# snippet_id (required) - The ID of a project snippet
# title (optional) - The title of a snippet
# title (optional) - The title of a snippet
# file_name (optional) - The name of a snippet file
# file_name (optional) - The name of a snippet file
...
@@ -111,7 +111,7 @@ module Gitlab
...
@@ -111,7 +111,7 @@ module Gitlab
# Delete a project snippet
# Delete a project snippet
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# snippet_id (required) - The ID of a project snippet
# snippet_id (required) - The ID of a project snippet
# Example Request:
# Example Request:
# DELETE /projects/:id/snippets/:snippet_id
# DELETE /projects/:id/snippets/:snippet_id
...
@@ -123,7 +123,7 @@ module Gitlab
...
@@ -123,7 +123,7 @@ module Gitlab
# Get a raw project snippet
# Get a raw project snippet
#
#
# Parameters:
# Parameters:
# id (required) - The
cod
e of a project
# id (required) - The
ID or code nam
e of a project
# snippet_id (required) - The ID of a project snippet
# snippet_id (required) - The ID of a project snippet
# Example Request:
# Example Request:
# GET /projects/:id/snippets/:snippet_id/raw
# GET /projects/:id/snippets/:snippet_id/raw
...
...
spec/api/projects_spec.rb
View file @
f9c6d8a4
...
@@ -25,11 +25,23 @@ describe Gitlab::API do
...
@@ -25,11 +25,23 @@ describe Gitlab::API do
describe
"GET /projects/:id"
do
describe
"GET /projects/:id"
do
it
"should return a project by id"
do
it
"should return a project by id"
do
get
"
#{
api_prefix
}
/projects/
#{
project
.
code
}
?private_token=
#{
user
.
private_token
}
"
get
"
#{
api_prefix
}
/projects/
#{
project
.
id
}
?private_token=
#{
user
.
private_token
}
"
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
project
.
name
json_response
[
'name'
].
should
==
project
.
name
json_response
[
'owner'
][
'email'
].
should
==
user
.
email
json_response
[
'owner'
][
'email'
].
should
==
user
.
email
end
end
it
"should return a project by code name"
do
get
"
#{
api_prefix
}
/projects/
#{
project
.
code
}
?private_token=
#{
user
.
private_token
}
"
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
project
.
name
end
it
"should return a 404 error if not found"
do
get
"
#{
api_prefix
}
/projects/42?private_token=
#{
user
.
private_token
}
"
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not found'
end
end
end
describe
"GET /projects/:id/repository/branches"
do
describe
"GET /projects/:id/repository/branches"
do
...
...
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