projects.md 5.1 KB
Newer Older
N
Nihad Abbasov 已提交
1 2
## List projects

R
Rob Taylor 已提交
3
Get a list of projects owned by the authenticated user.
N
Nihad Abbasov 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17

```
GET /projects
```

```json
[
  {
    "id": 3,
    "name": "rails",
    "description": null,
    "default_branch": "master",
    "owner": {
      "id": 1,
18
      "username": "john_smith",
N
Nihad Abbasov 已提交
19 20 21 22 23
      "email": "john@example.com",
      "name": "John Smith",
      "blocked": false,
      "created_at": "2012-05-23T08:00:58Z"
    },
24
    "public": true,
25 26
    "path": "rails",
    "path_with_namespace": "rails/rails",
N
Nihad Abbasov 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39
    "issues_enabled": false,
    "merge_requests_enabled": false,
    "wall_enabled": true,
    "wiki_enabled": true,
    "created_at": "2012-05-23T08:05:02Z"
  },
  {
    "id": 5,
    "name": "gitlab",
    "description": null,
    "default_branch": "api",
    "owner": {
      "id": 1,
40
      "username": "john_smith",
N
Nihad Abbasov 已提交
41 42 43 44 45
      "email": "john@example.com",
      "name": "John Smith",
      "blocked": false,
      "created_at": "2012-05-23T08:00:58Z"
    },
46
    "public": true,
47 48
    "path": "gitlab",
    "path_with_namespace": "randx/gitlab",
N
Nihad Abbasov 已提交
49 50 51 52 53 54 55 56 57 58 59
    "issues_enabled": true,
    "merge_requests_enabled": true,
    "wall_enabled": true,
    "wiki_enabled": true,
    "created_at": "2012-05-30T12:49:20Z"
  }
]
```

## Single project

R
Rob Taylor 已提交
60
Get a specific project, identified by project ID, which is owned by the authentication user.
N
Nihad Abbasov 已提交
61 62 63 64 65 66 67

```
GET /projects/:id
```

Parameters:

68
+ `id` (required) - The ID of a project
N
Nihad Abbasov 已提交
69

A
Alex Denisov 已提交
70 71 72 73 74 75 76 77
```json
{
  "id": 5,
  "name": "gitlab",
  "description": null,
  "default_branch": "api",
  "owner": {
    "id": 1,
78
    "username": "john_smith",
A
Alex Denisov 已提交
79 80 81 82 83
    "email": "john@example.com",
    "name": "John Smith",
    "blocked": false,
    "created_at": "2012-05-23T08:00:58Z"
  },
84
  "public": true,
85 86
  "path": "gitlab",
  "path_with_namespace": "randx/gitlab",
A
Alex Denisov 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
  "issues_enabled": true,
  "merge_requests_enabled": true,
  "wall_enabled": true,
  "wiki_enabled": true,
  "created_at": "2012-05-30T12:49:20Z"
}
```

## Create project

Create new project owned by user

```
POST /projects
```

Parameters:

+ `name` (required) - new project name
N
Nihad Abbasov 已提交
106
+ `description` (optional) - short project description
107 108 109 110 111
+ `default_branch` (optional) - 'master' by default
+ `issues_enabled` (optional) - enabled by default
+ `wall_enabled` (optional) - enabled by default
+ `merge_requests_enabled` (optional) - enabled by default
+ `wiki_enabled` (optional) - enabled by default
A
Alex Denisov 已提交
112

113 114 115
Will return created project with status `201 Created` on success, or `404 Not
found` on fail.

N
Nihad Abbasov 已提交
116
## List project team members
M
miks 已提交
117

N
Nihad Abbasov 已提交
118
Get a list of project team members.
M
miks 已提交
119 120

```
N
Nihad Abbasov 已提交
121
GET /projects/:id/members
M
miks 已提交
122 123 124 125
```

Parameters:

126
+ `id` (required) - The ID of a project
V
Valeriy Sizov 已提交
127
+ `query`         - Query string
M
miks 已提交
128

N
Nihad Abbasov 已提交
129
## Get project team member
M
miks 已提交
130

N
Nihad Abbasov 已提交
131
Get a project team member.
132

N
Nihad Abbasov 已提交
133 134 135 136 137
```
GET /projects/:id/members/:user_id
```

Parameters:
138

139
+ `id` (required) - The ID of a project
N
Nihad Abbasov 已提交
140 141 142 143 144 145
+ `user_id` (required) - The ID of a user

```json
{

  "id": 1,
146
  "username": "john_smith",
N
Nihad Abbasov 已提交
147 148 149 150 151 152
  "email": "john@example.com",
  "name": "John Smith",
  "blocked": false,
  "created_at": "2012-05-23T08:00:58Z",
  "access_level": 40
}
153
```
N
Nihad Abbasov 已提交
154 155 156 157 158 159 160

## Add project team member

Add a user to a project team.

```
POST /projects/:id/members
161 162 163 164
```

Parameters:

165
+ `id` (required) - The ID of a project
N
Nihad Abbasov 已提交
166 167
+ `user_id` (required) - The ID of a user to add
+ `access_level` (required) - Project access level
168

M
miks 已提交
169 170
Will return status `201 Created` on success, or `404 Not found` on fail.

N
Nihad Abbasov 已提交
171
## Edit project team member
M
miks 已提交
172

N
Nihad Abbasov 已提交
173
Update project team member to specified access level.
M
miks 已提交
174 175

```
N
Nihad Abbasov 已提交
176
PUT /projects/:id/members/:user_id
M
miks 已提交
177 178 179 180
```

Parameters:

181
+ `id` (required) - The ID of a project
N
Nihad Abbasov 已提交
182 183
+ `user_id` (required) - The ID of a team member
+ `access_level` (required) - Project access level
M
miks 已提交
184 185 186

Will return status `200 OK` on success, or `404 Not found` on fail.

N
Nihad Abbasov 已提交
187
## Remove project team member
M
miks 已提交
188

N
Nihad Abbasov 已提交
189
Removes user from project team.
M
miks 已提交
190 191

```
N
Nihad Abbasov 已提交
192
DELETE /projects/:id/members/:user_id
M
miks 已提交
193 194 195 196
```

Parameters:

197
+ `id` (required) - The ID of a project
N
Nihad Abbasov 已提交
198
+ `user_id` (required) - The ID of a team member
M
miks 已提交
199

N
Nihad Abbasov 已提交
200
Status code `200` will be returned on success.
N
Nihad Abbasov 已提交
201

202
## List project hooks
M
miks 已提交
203

204
Get list for project hooks
M
miks 已提交
205 206 207 208 209 210 211

```
GET /projects/:id/hooks
```

Parameters:

212
+ `id` (required) - The ID of a project
M
miks 已提交
213 214 215

Will return hooks with status `200 OK` on success, or `404 Not found` on fail.

216 217 218 219 220 221 222 223 224 225
## Get project hook

Get hook for project

```
GET /projects/:id/hooks/:hook_id
```

Parameters:

226
+ `id` (required) - The ID of a project
227 228 229 230
+ `hook_id` (required) - The ID of a project hook

Will return hook with status `200 OK` on success, or `404 Not found` on fail.

M
miks 已提交
231 232 233 234 235 236 237 238 239 240
## Add project hook

Add hook to project

```
POST /projects/:id/hooks
```

Parameters:

241
+ `id` (required) - The ID of a project
M
miks 已提交
242 243 244 245
+ `url` (required) - The hook URL

Will return status `201 Created` on success, or `404 Not found` on fail.

246 247 248 249 250 251 252 253 254 255
## Edit project hook

Edit hook for project

```
PUT /projects/:id/hooks/:hook_id
```

Parameters:

256
+ `id` (required) - The ID of a project
257 258 259 260 261 262
+ `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.


M
miks 已提交
263 264 265 266 267 268 269 270 271 272
## Delete project hook

Delete hook from project

```
DELETE /projects/:id/hooks
```

Parameters:

273
+ `id` (required) - The ID of a project
M
miks 已提交
274 275 276
+ `hook_id` (required) - The ID of hook to delete

Will return status `200 OK` on success, or `404 Not found` on fail.