Skip to content

Commit 97b2d78

Browse files
committed
Merge branch 'doc_refactor_system_hooks_api' into 'master'
Refactor system_hooks API documentation See merge request !2475
2 parents df4d676 + 23a878c commit 97b2d78

File tree

1 file changed

+94
-24
lines changed

1 file changed

+94
-24
lines changed

doc/api/system_hooks.md

+94-24
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,140 @@
11
# System hooks
22

3-
All methods require admin authorization.
3+
All methods require administrator authorization.
44

5-
The URL endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks).
5+
The URL endpoint of the system hooks can also be configured using the UI in
6+
the admin area under **Hooks** (`/admin/hooks`).
7+
8+
Read more about [system hooks](../system_hooks/system_hooks.md).
69

710
## List system hooks
811

9-
Get list of system hooks
12+
Get a list of all system hooks.
13+
14+
---
1015

1116
```
1217
GET /hooks
1318
```
1419

15-
Parameters:
20+
Example request:
21+
22+
```bash
23+
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks
24+
```
1625

17-
- **none**
26+
Example response:
1827

1928
```json
2029
[
21-
{
22-
"id": 3,
23-
"url": "http://example.com/hook",
24-
"created_at": "2013-10-02T10:15:31Z"
25-
}
30+
{
31+
"id" : 1,
32+
"url" : "https://gitlab.example.com/hook",
33+
"created_at" : "2015-11-04T20:07:35.874Z"
34+
}
2635
]
2736
```
2837

29-
## Add new system hook hook
38+
## Add new system hook
39+
40+
Add a new system hook.
41+
42+
---
3043

3144
```
3245
POST /hooks
3346
```
3447

35-
Parameters:
48+
| Attribute | Type | Required | Description |
49+
| --------- | ---- | -------- | ----------- |
50+
| `url` | string | yes | The hook URL |
51+
52+
Example request:
53+
54+
```bash
55+
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/hooks?url=https://gitlab.example.com/hook"
56+
```
57+
58+
Example response:
3659

37-
- `url` (required) - The hook URL
60+
```json
61+
[
62+
{
63+
"id" : 2,
64+
"url" : "https://gitlab.example.com/hook",
65+
"created_at" : "2015-11-04T20:07:35.874Z"
66+
}
67+
]
68+
```
3869

3970
## Test system hook
4071

4172
```
4273
GET /hooks/:id
4374
```
4475

45-
Parameters:
76+
| Attribute | Type | Required | Description |
77+
| --------- | ---- | -------- | ----------- |
78+
| `id` | integer | yes | The ID of the hook |
4679

47-
- `id` (required) - The ID of hook
80+
Example request:
81+
82+
```bash
83+
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2
84+
```
85+
86+
Example response:
4887

4988
```json
5089
{
51-
"event_name": "project_create",
52-
"name": "Ruby",
53-
"path": "ruby",
54-
"project_id": 1,
55-
"owner_name": "Someone",
56-
"owner_email": "[email protected]"
90+
"project_id" : 1,
91+
"owner_email" : "[email protected]",
92+
"owner_name" : "Someone",
93+
"name" : "Ruby",
94+
"path" : "ruby",
95+
"event_name" : "project_create"
5796
}
5897
```
5998

6099
## Delete system hook
61100

62-
Deletes a system hook. This is an idempotent API function and returns `200 OK` even if the hook is not available. If the hook is deleted it is also returned as JSON.
101+
Deletes a system hook. This is an idempotent API function and returns `200 OK`
102+
even if the hook is not available.
103+
104+
If the hook is deleted, a JSON object is returned. An error is raised if the
105+
hook is not found.
106+
107+
---
63108

64109
```
65110
DELETE /hooks/:id
66111
```
67112

68-
Parameters:
113+
| Attribute | Type | Required | Description |
114+
| --------- | ---- | -------- | ----------- |
115+
| `id` | integer | yes | The ID of the hook |
116+
117+
Example request:
69118

70-
- `id` (required) - The ID of hook
119+
```bash
120+
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2
121+
```
122+
123+
Example response:
124+
125+
```json
126+
{
127+
"note_events" : false,
128+
"project_id" : null,
129+
"enable_ssl_verification" : true,
130+
"url" : "https://gitlab.example.com/hook",
131+
"updated_at" : "2015-11-04T20:12:15.931Z",
132+
"issues_events" : false,
133+
"merge_requests_events" : false,
134+
"created_at" : "2015-11-04T20:12:15.931Z",
135+
"service_id" : null,
136+
"id" : 2,
137+
"push_events" : true,
138+
"tag_push_events" : false
139+
}
140+
```

0 commit comments

Comments
 (0)