Skip to content

Commit a894797

Browse files
committed
updated docs: marked Repositories/Services as deprecated ; added doc for Repositories/WebHooks [ci skip]
1 parent 62919f2 commit a894797

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

docs/examples/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ title: Examples
4646
- [Pull requests](repositories/pull-requests.html)
4747
- [Comments](repositories/pull-requests/comments.html)
4848
- [Repository](repositories/repository.html)
49-
- [Services](repositories/services.html)
49+
- ~~[Services](repositories/services.html)~~ (deprecated since 0.7.0 -- @see [WebHooks](repositories/webhooks.html))
50+
- [Hooks](repositories/webhooks.html)
5051
- [Src](repositories/src.html)
5152
- [Wiki](repositories/wiki.html)
5253
- [Teams](teams.html)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: default
3+
permalink: /examples/repositories/webhooks.html
4+
title: WebHooks
5+
---
6+
7+
# WebHooks
8+
9+
This resource manages webhooks on a repository. The administrators of the repository are
10+
the only users who can create, access, update, or delete the webhook.
11+
12+
### Prepare:
13+
14+
```php
15+
$uuid = '30b60aee-9cdf-407d-901c-2de106ee0c9d'; // unique identifier of the webhook
16+
$hooks = new Bitbucket\API\Repositories\Hooks();
17+
18+
$hooks->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
19+
```
20+
21+
### Get a webhook:
22+
23+
```php
24+
$hooks->get($account_name, $repo_slug, $uuid);
25+
```
26+
27+
**HINT:** You can use `$hooks->all()` method to get a list of all available hooks and their unique identifiers.
28+
29+
### Get a list of webhooks:
30+
31+
```php
32+
$hooks->all($account_name, $repo_slug);
33+
```
34+
35+
### Create a new webhook:
36+
37+
```php
38+
$hook->create($account_name, $repo_slug, array(
39+
'description' => 'Webhook Description',
40+
'url' => 'http://requestb.in/xxx',
41+
'active' => true,
42+
'events' => array(
43+
'repo:push',
44+
'issue:created',
45+
'issue:updated'
46+
)
47+
));
48+
```
49+
50+
**HINT:** For a full list of available events, see [Event Payloads](https://confluence.atlassian.com/display/BITBUCKET/Event+Payloads) page.
51+
52+
### Update a webhook:
53+
54+
Add a new event `pullrequest:approved` to our webhook:
55+
56+
```php
57+
$hook->update($account_name, $repo_slug, $uuid, array(
58+
'description' => 'Webhook Description',
59+
'url' => 'http://requestb.in/xxx',
60+
'active' => true,
61+
'events' => array(
62+
'repo:push',
63+
'issue:created',
64+
'issue:updated',
65+
'pullrequest:approved'
66+
)
67+
));
68+
```
69+
70+
**HINT:** Bitbucket doesn't offer a patch endpoint, so you need to send the entire object represensation in order to update.
71+
72+
### Delete a webhook:
73+
74+
```php
75+
$hook->delete($account_name, $repo_slug, $uuid);
76+
```
77+
78+
----
79+
80+
#### Related:
81+
* [Authentication]({{ site.url }}/examples/authentication.html)
82+
* [BB Wiki](https://confluence.atlassian.com/display/BITBUCKET/webhooks+Resource)

0 commit comments

Comments
 (0)