projects.md 5.3 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 18 19

```
GET /projects
```

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

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

A
Alex Denisov 已提交
70 71 72 73 74 75 76 77 78 79
```json
{
  "id": 5,
  "code": "gitlab",
  "name": "gitlab",
  "description": null,
  "path": "gitlab",
  "default_branch": "api",
  "owner": {
    "id": 1,
80
    "username": "john_smith",
A
Alex Denisov 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    "email": "john@example.com",
    "name": "John Smith",
    "blocked": false,
    "created_at": "2012-05-23T08:00:58Z"
  },
  "private": true,
  "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
A
Alex Denisov 已提交
106 107
+ `code` (optional) - new project code, uses project name if not set
+ `path` (optional) - new project path, uses project name if not set
N
Nihad Abbasov 已提交
108
+ `description` (optional) - short project description
109 110 111 112 113
+ `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 已提交
114

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

N
Nihad Abbasov 已提交
118
## List project team members
M
miks 已提交
119

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

```
N
Nihad Abbasov 已提交
123
GET /projects/:id/members
M
miks 已提交
124 125 126 127 128
```

Parameters:

+ `id` (required) - The ID or code name of a project
V
Valeriy Sizov 已提交
129
+ `query`         - Query string
M
miks 已提交
130

N
Nihad Abbasov 已提交
131
## Get project team member
M
miks 已提交
132

N
Nihad Abbasov 已提交
133
Get a project team member.
134

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

Parameters:
140

N
Nihad Abbasov 已提交
141 142 143 144 145 146 147
+ `id` (required) - The ID or code name of a project
+ `user_id` (required) - The ID of a user

```json
{

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

## Add project team member

Add a user to a project team.

```
POST /projects/:id/members
163 164 165 166 167
```

Parameters:

+ `id` (required) - The ID or code name of a project
N
Nihad Abbasov 已提交
168 169
+ `user_id` (required) - The ID of a user to add
+ `access_level` (required) - Project access level
170

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

N
Nihad Abbasov 已提交
173
## Edit project team member
M
miks 已提交
174

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

```
N
Nihad Abbasov 已提交
178
PUT /projects/:id/members/:user_id
M
miks 已提交
179 180 181 182 183
```

Parameters:

+ `id` (required) - The ID or code name of a project
N
Nihad Abbasov 已提交
184 185
+ `user_id` (required) - The ID of a team member
+ `access_level` (required) - Project access level
M
miks 已提交
186 187 188

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

N
Nihad Abbasov 已提交
189
## Remove project team member
M
miks 已提交
190

N
Nihad Abbasov 已提交
191
Removes user from project team.
M
miks 已提交
192 193

```
N
Nihad Abbasov 已提交
194
DELETE /projects/:id/members/:user_id
M
miks 已提交
195 196 197 198 199
```

Parameters:

+ `id` (required) - The ID or code name of a project
N
Nihad Abbasov 已提交
200
+ `user_id` (required) - The ID of a team member
M
miks 已提交
201

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

204
## List project hooks
M
miks 已提交
205

206
Get list for project hooks
M
miks 已提交
207 208 209 210 211 212 213 214 215 216 217

```
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.

218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
## Get project hook

Get hook for project

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

Parameters:

+ `id` (required) - The ID or code name of a project
+ `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 已提交
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
## 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.

248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
## Edit project hook

Edit hook for project

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

Parameters:

+ `id` (required) - The ID or code name of a project
+ `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 已提交
265 266 267 268 269 270 271 272 273 274 275 276 277 278
## 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.