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
Boxiang Sun
gitlab-ce
Commits
18a6f31b
Commit
18a6f31b
authored
Oct 14, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/api_iids' of /home/git/repositories/gitlab/gitlabhq
parents
d20db103
02693b72
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
13 deletions
+40
-13
doc/api/README.md
doc/api/README.md
+18
-1
doc/api/issues.md
doc/api/issues.md
+3
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+2
-0
doc/api/milestones.md
doc/api/milestones.md
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+13
-12
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+1
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+1
-0
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+1
-0
No files found.
doc/api/README.md
View file @
18a6f31b
...
@@ -96,13 +96,30 @@ curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: username" "h
...
@@ -96,13 +96,30 @@ curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: username" "h
curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: 23" "http://example.com/api/v3/projects"
curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: 23" "http://example.com/api/v3/projects"
```
```
##
##
Pagination
## Pagination
When listing resources you can pass the following parameters:
When listing resources you can pass the following parameters:
+
`page`
(default:
`1`
) - page number
+
`page`
(default:
`1`
) - page number
+
`per_page`
(default:
`20`
, max:
`100`
) - number of items to list per page
+
`per_page`
(default:
`20`
, max:
`100`
) - number of items to list per page
## id vs iid
When you work with API you may notice two similar fields in api entites: id and iid.
The main difference between them is scope. Example:
Issue
id: 46
iid: 5
*
id - is uniq across all Issues table. It used for any api calls.
*
iid - is uniq only in scope of single project. When you browse issues or merge requests with Web UI - you see iid.
So if you want to get issue with api you use
`http://host/api/v3/.../issues/:id.json`
But when you want to create a link to web page - use
`http:://host/project/issues/:iid.json`
## Contents
## Contents
+
[
Users
](
users.md
)
+
[
Users
](
users.md
)
...
...
doc/api/issues.md
View file @
18a6f31b
...
@@ -11,6 +11,7 @@ GET /issues
...
@@ -11,6 +11,7 @@ GET /issues
[
[
{
{
"id"
:
43
,
"id"
:
43
,
"iid"
:
3
,
"project_id"
:
8
,
"project_id"
:
8
,
"title"
:
"4xx/5xx pages"
,
"title"
:
"4xx/5xx pages"
,
"description"
:
""
,
"description"
:
""
,
...
@@ -31,6 +32,7 @@ GET /issues
...
@@ -31,6 +32,7 @@ GET /issues
},
},
{
{
"id"
:
42
,
"id"
:
42
,
"iid"
:
4
,
"project_id"
:
8
,
"project_id"
:
8
,
"title"
:
"Add user settings"
,
"title"
:
"Add user settings"
,
"description"
:
""
,
"description"
:
""
,
...
@@ -100,6 +102,7 @@ Parameters:
...
@@ -100,6 +102,7 @@ Parameters:
```
json
```
json
{
{
"id"
:
42
,
"id"
:
42
,
"iid"
:
3
,
"project_id"
:
8
,
"project_id"
:
8
,
"title"
:
"Add user settings"
,
"title"
:
"Add user settings"
,
"description"
:
""
,
"description"
:
""
,
...
...
doc/api/merge_requests.md
View file @
18a6f31b
...
@@ -15,6 +15,7 @@ Parameters:
...
@@ -15,6 +15,7 @@ Parameters:
[
[
{
{
"id"
:
1
,
"id"
:
1
,
"iid"
:
1
,
"target_branch"
:
"master"
,
"target_branch"
:
"master"
,
"source_branch"
:
"test1"
,
"source_branch"
:
"test1"
,
"project_id"
:
3
,
"project_id"
:
3
,
...
@@ -59,6 +60,7 @@ Parameters:
...
@@ -59,6 +60,7 @@ Parameters:
```
json
```
json
{
{
"id"
:
1
,
"id"
:
1
,
"iid"
:
1
,
"target_branch"
:
"master"
,
"target_branch"
:
"master"
,
"source_branch"
:
"test1"
,
"source_branch"
:
"test1"
,
"project_id"
:
3
,
"project_id"
:
3
,
...
...
doc/api/milestones.md
View file @
18a6f31b
...
@@ -10,6 +10,7 @@ GET /projects/:id/milestones
...
@@ -10,6 +10,7 @@ GET /projects/:id/milestones
[
[
{
{
"id"
:
12
,
"id"
:
12
,
"iid"
:
3
,
"project_id"
:
16
,
"project_id"
:
16
,
"title"
:
"10.0"
,
"title"
:
"10.0"
,
"description"
:
"Version"
,
"description"
:
"Version"
,
...
...
lib/api/entities.rb
View file @
18a6f31b
...
@@ -91,15 +91,16 @@ module API
...
@@ -91,15 +91,16 @@ module API
expose
:expires_at
,
:updated_at
,
:created_at
expose
:expires_at
,
:updated_at
,
:created_at
end
end
class
Milestone
<
Grape
::
Entity
class
ProjectEntity
<
Grape
::
Entity
expose
:id
expose
:id
,
:iid
expose
(
:project_id
)
{
|
milestone
|
milestone
.
project
.
id
}
expose
(
:project_id
)
{
|
entity
|
entity
.
project
.
id
}
end
class
Milestone
<
ProjectEntity
expose
:title
,
:description
,
:due_date
,
:state
,
:updated_at
,
:created_at
expose
:title
,
:description
,
:due_date
,
:state
,
:updated_at
,
:created_at
end
end
class
Issue
<
Grape
::
Entity
class
Issue
<
ProjectEntity
expose
:id
expose
(
:project_id
)
{
|
issue
|
issue
.
project
.
id
}
expose
:title
,
:description
expose
:title
,
:description
expose
:label_list
,
as: :labels
expose
:label_list
,
as: :labels
expose
:milestone
,
using:
Entities
::
Milestone
expose
:milestone
,
using:
Entities
::
Milestone
...
@@ -107,14 +108,14 @@ module API
...
@@ -107,14 +108,14 @@ module API
expose
:state
,
:updated_at
,
:created_at
expose
:state
,
:updated_at
,
:created_at
end
end
class
SSHKey
<
Grape
::
Entity
class
MergeRequest
<
ProjectEntity
expose
:id
,
:title
,
:key
,
:created_at
expose
:target_branch
,
:source_branch
,
:title
,
:state
,
:upvotes
,
:downvotes
expose
:author
,
:assignee
,
using:
Entities
::
UserBasic
expose
:source_project_id
,
:target_project_id
end
end
class
MergeRequest
<
Grape
::
Entity
class
SSHKey
<
Grape
::
Entity
expose
:id
,
:target_branch
,
:source_branch
,
:title
,
:state
,
:upvotes
,
:downvotes
expose
:id
,
:title
,
:key
,
:created_at
expose
:target_project_id
,
as: :project_id
expose
:author
,
:assignee
,
using:
Entities
::
UserBasic
end
end
class
Note
<
Grape
::
Entity
class
Note
<
Grape
::
Entity
...
...
spec/requests/api/issues_spec.rb
View file @
18a6f31b
...
@@ -42,6 +42,7 @@ describe API::API do
...
@@ -42,6 +42,7 @@ describe API::API do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
issue
.
title
json_response
[
'title'
].
should
==
issue
.
title
json_response
[
'iid'
].
should
==
issue
.
iid
end
end
it
"should return 404 if issue id not found"
do
it
"should return 404 if issue id not found"
do
...
...
spec/requests/api/merge_requests_spec.rb
View file @
18a6f31b
...
@@ -34,6 +34,7 @@ describe API::API do
...
@@ -34,6 +34,7 @@ describe API::API do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
merge_request
.
title
json_response
[
'title'
].
should
==
merge_request
.
title
json_response
[
'iid'
].
should
==
merge_request
.
iid
end
end
it
"should return a 404 error if merge_request_id not found"
do
it
"should return a 404 error if merge_request_id not found"
do
...
...
spec/requests/api/milestones_spec.rb
View file @
18a6f31b
...
@@ -30,6 +30,7 @@ describe API::API do
...
@@ -30,6 +30,7 @@ describe API::API do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
milestone
.
title
json_response
[
'title'
].
should
==
milestone
.
title
json_response
[
'iid'
].
should
==
milestone
.
iid
end
end
it
"should return 401 error if user not authenticated"
do
it
"should return 401 error if user not authenticated"
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