projects.md 9.5 KB
Newer Older
1 2 3
## Projects

### List projects
N
Nihad Abbasov 已提交
4

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

```
GET /projects
```

```json
[
  {
    "id": 3,
    "name": "rails",
    "description": null,
    "default_branch": "master",
    "owner": {
      "id": 1,
20
      "username": "john_smith",
N
Nihad Abbasov 已提交
21 22 23 24 25
      "email": "john@example.com",
      "name": "John Smith",
      "blocked": false,
      "created_at": "2012-05-23T08:00:58Z"
    },
26
    "public": true,
27 28
    "path": "rails",
    "path_with_namespace": "rails/rails",
N
Nihad Abbasov 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41
    "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,
42
      "username": "john_smith",
N
Nihad Abbasov 已提交
43 44 45 46 47
      "email": "john@example.com",
      "name": "John Smith",
      "blocked": false,
      "created_at": "2012-05-23T08:00:58Z"
    },
48
    "public": true,
49 50
    "path": "gitlab",
    "path_with_namespace": "randx/gitlab",
N
Nihad Abbasov 已提交
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"
  }
]
```

60 61

### Get single project
N
Nihad Abbasov 已提交
62

63 64
Get a specific project, identified by project ID or NAME, which is owned by the authentication user.
Currently namespaced projects cannot retrieved by name.
N
Nihad Abbasov 已提交
65 66 67 68 69 70 71

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

Parameters:

72
+ `id` (required) - The ID or NAME of a project
N
Nihad Abbasov 已提交
73

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

99 100

### Create project
A
Alex Denisov 已提交
101

102
Creates new project owned by user.
A
Alex Denisov 已提交
103 104 105 106 107 108 109 110

```
POST /projects
```

Parameters:

+ `name` (required) - new project name
N
Nihad Abbasov 已提交
111
+ `description` (optional) - short project description
112 113 114 115 116
+ `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 已提交
117

118
**Project access levels**
119

120
The project access levels are defined in the `user_project.rb` class. Currently, these levels are recoginized:
121 122 123 124 125 126 127 128

```
  GUEST     = 10
  REPORTER  = 20
  DEVELOPER = 30
  MASTER    = 40
```

129

130 131 132
### Create project for user

Creates a new project owned by user. Available only for admins.
133 134 135 136 137 138 139 140 141 142 143 144

```
POST /projects/user/:user_id
```

Parameters:

+ `user_id` (required) - user_id of owner
+ `name` (required) - new project name
+ `description` (optional) - short project description
+ `default_branch` (optional) - 'master' by default
+ `issues_enabled` (optional) - enabled by default
145 146 147
+ `wall_enabled` (optional) - enabled by default
+ `merge_requests_enabled` (optional) - enabled by default
+ `wiki_enabled` (optional) - enabled by default
A
Alex Denisov 已提交
148

149

150 151 152 153

## Team members

### List project team members
M
miks 已提交
154

N
Nihad Abbasov 已提交
155
Get a list of project team members.
M
miks 已提交
156 157

```
N
Nihad Abbasov 已提交
158
GET /projects/:id/members
M
miks 已提交
159 160 161 162
```

Parameters:

163
+ `id` (required) - The ID or NAME of a project
164
+ `query` (optional) - Query string to search for members
165 166 167


### Get project team member
M
miks 已提交
168

169
Gets a project team member.
170

N
Nihad Abbasov 已提交
171 172 173 174 175
```
GET /projects/:id/members/:user_id
```

Parameters:
176

177
+ `id` (required) - The ID or NAME of a project
N
Nihad Abbasov 已提交
178 179 180 181 182
+ `user_id` (required) - The ID of a user

```json
{
  "id": 1,
183
  "username": "john_smith",
N
Nihad Abbasov 已提交
184 185 186 187 188 189
  "email": "john@example.com",
  "name": "John Smith",
  "blocked": false,
  "created_at": "2012-05-23T08:00:58Z",
  "access_level": 40
}
190
```
N
Nihad Abbasov 已提交
191

192 193

### Add project team member
N
Nihad Abbasov 已提交
194

195 196
Adds a user to a project team. This is an idempotent method and can be called multiple times
with the same parameters. Adding team membership to a user that is already a member does not
197
affect the existing membership.
N
Nihad Abbasov 已提交
198 199 200

```
POST /projects/:id/members
201 202 203 204
```

Parameters:

205
+ `id` (required) - The ID or NAME of a project
N
Nihad Abbasov 已提交
206 207
+ `user_id` (required) - The ID of a user to add
+ `access_level` (required) - Project access level
208

209 210

### Edit project team member
M
miks 已提交
211

212
Updates project team member to a specified access level.
M
miks 已提交
213 214

```
N
Nihad Abbasov 已提交
215
PUT /projects/:id/members/:user_id
M
miks 已提交
216 217 218 219
```

Parameters:

220
+ `id` (required) - The ID or NAME of a project
N
Nihad Abbasov 已提交
221 222
+ `user_id` (required) - The ID of a team member
+ `access_level` (required) - Project access level
M
miks 已提交
223

224 225

### Remove project team member
M
miks 已提交
226

N
Nihad Abbasov 已提交
227
Removes user from project team.
M
miks 已提交
228 229

```
N
Nihad Abbasov 已提交
230
DELETE /projects/:id/members/:user_id
M
miks 已提交
231 232 233 234
```

Parameters:

235
+ `id` (required) - The ID or NAME of a project
N
Nihad Abbasov 已提交
236
+ `user_id` (required) - The ID of a team member
M
miks 已提交
237

238 239 240
This method is idempotent and can be called multiple times with the same parameters.
Revoking team membership for a user who is not currently a team member is considered success.
Please note that the returned JSON currently differs slightly. Thus you should not
241
rely on the returned JSON structure.
N
Nihad Abbasov 已提交
242

M
miks 已提交
243

244 245 246 247 248
## Hooks

### List project hooks

Get list of project hooks.
M
miks 已提交
249 250 251 252 253 254 255

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

Parameters:

256
+ `id` (required) - The ID or NAME of a project
M
miks 已提交
257 258


259
### Get project hook
260

261
Get a specific hook for project.
262 263 264 265 266

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

267
Parameters:
268

269
+ `id` (required) - The ID or NAME of a project
270 271
+ `hook_id` (required) - The ID of a project hook

272 273 274 275 276 277 278 279
```json
{
  "id": 1,
  "url": "http://example.com/hook",
  "created_at": "2012-10-12T17:04:47Z"
}
```

M
miks 已提交
280

281 282 283
### Add project hook

Adds a hook to project.
M
miks 已提交
284 285 286 287 288 289 290

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

Parameters:

291
+ `id` (required) - The ID or NAME of a project
M
miks 已提交
292 293
+ `url` (required) - The hook URL

294

295 296 297
### Edit project hook

Edits a hook for project.
298 299 300 301 302 303 304

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

Parameters:

305
+ `id` (required) - The ID or NAME of a project
306 307 308 309
+ `hook_id` (required) - The ID of a project hook
+ `url` (required) - The hook URL


310
### Delete project hook
M
miks 已提交
311

312 313
Removes a hook from project. This is an idempotent method and can be called multiple times.
Either the hook is available or not.
M
miks 已提交
314 315

```
316
DELETE /projects/:id/hooks/
M
miks 已提交
317 318 319 320
```

Parameters:

321
+ `id` (required) - The ID or NAME of a project
M
miks 已提交
322 323
+ `hook_id` (required) - The ID of hook to delete

324 325
Note the JSON response differs if the hook is available or not. If the project hook
is available before it is returned in the JSON response or an empty response is returned.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383


## Branches

### List branches

Lists all branches of a project.

```
GET /projects/:id/repository/branches
```

Parameters:

+ `id` (required) - The ID of the project


### List single branch

Lists a specific branch of a project.

```
GET /projects/:id/repository/branches/:branch
```

Parameters:

+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.


### Protect single branch

Protects a single branch of a project.

```
PUT /projects/:id/repository/branches/:branch/protect
```

Parameters:

+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.


### Unprotect single branch

Unprotects a single branch of a project.

```
PUT /projects/:id/repository/branches/:branch/unprotect
```

Parameters:

+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.

384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420

### List tags

Lists all tags of a project.

```
GET /projects/:id/repository/tags
```

Parameters:

+ `id` (required) - The ID of the project


### List commits

Lists all commits with pagination. If the optional `ref_name` name is not given the commits of
the default branch (usually master) are returned.

```
GET /projects/:id/repository/commits
```

Parameters:

+ `id` (required) - The Id of the project
+ `ref_name` (optional) - The name of a repository branch or tag
+ `page` (optional) - The page of commits to return (`0` default)
+ `per_page` (optional) - The number of commits per page (`20` default)

Returns values:

+ `200 Ok` on success and a list with commits
+ `404 Not Found` if project with id or the branch with `ref_name` not found



421 422 423
## Deploy Keys

### List deploy keys
424

M
Matt Humphrey 已提交
425
Get a list of a project's deploy keys.
426 427

```
M
Matt Humphrey 已提交
428
GET /projects/:id/keys
429 430 431 432 433 434
```

Parameters:

+ `id` (required) - The ID of the project

M
Matt Humphrey 已提交
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
```json
[
  {
    "id": 1,
    "title" : "Public key"
    "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4
      596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4
      soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
  },
  {
    "id": 3,
    "title" : "Another Public key"
    "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4
      596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4
      soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
  }
]
452 453 454
```


455
### Single deploy key
456

M
Matt Humphrey 已提交
457
Get a single key.
458 459

```
M
Matt Humphrey 已提交
460
GET /projects/:id/keys/:key_id
461 462 463 464 465
```

Parameters:

+ `id` (required) - The ID of the project
466
+ `key_id` (required) - The ID of the deploy key
467

M
Matt Humphrey 已提交
468 469 470 471 472 473 474 475 476
```json
{
  "id": 1,
  "title" : "Public key"
  "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4
      596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4
      soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
}
```
477 478


479 480 481
### Add deploy key

Creates a new deploy key for a project.
482 483

```
M
Matt Humphrey 已提交
484
POST /projects/:id/keys
485 486 487 488 489
```

Parameters:

+ `id` (required) - The ID of the project
490 491
+ `title` (required) - New deploy key's title
+ `key` (required) - New deploy key
492 493


494
### Delete deploy key
495

M
Matt Humphrey 已提交
496
Delete a deploy key from a project
497 498

```
M
Matt Humphrey 已提交
499
DELETE /projects/:id/keys/:key_id
500 501
```

M
Matt Humphrey 已提交
502
Parameters:
503 504

+ `id` (required) - The ID of the project
505
+ `key_id` (required) - The ID of the deploy key
506